Toggle navigation
Documentation
Big picture
The finite element method
The data structure
Not-so-quick guide
Optimisation
Order of action functions
Example codes and tutorials
List of example codes and tutorials
Meshing
Solvers
MPI parallel processing
Post-processing/visualisation
Other
Change log
Creating documentation
Coding conventions
Index
FAQ
About
People
Contact/Get involved
Publications
Acknowledgements
Copyright
Picture show
Go
demo_drivers
axisym_solid
shell
benchmark_elements.cc
Go to the documentation of this file.
1
// LIC// ====================================================================
2
// LIC// This file forms part of oomph-lib, the object-oriented,
3
// LIC// multi-physics finite-element library, available
4
// LIC// at http://www.oomph-lib.org.
5
// LIC//
6
// LIC// Copyright (C) 2006-2026 Matthias Heil and Andrew Hazel
7
// LIC//
8
// LIC// This library is free software; you can redistribute it and/or
9
// LIC// modify it under the terms of the GNU Lesser General Public
10
// LIC// License as published by the Free Software Foundation; either
11
// LIC// version 2.1 of the License, or (at your option) any later version.
12
// LIC//
13
// LIC// This library is distributed in the hope that it will be useful,
14
// LIC// but WITHOUT ANY WARRANTY; without even the implied warranty of
15
// LIC// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
// LIC// Lesser General Public License for more details.
17
// LIC//
18
// LIC// You should have received a copy of the GNU Lesser General Public
19
// LIC// License along with this library; if not, write to the Free Software
20
// LIC// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21
// LIC// 02110-1301 USA.
22
// LIC//
23
// LIC// The authors may be contacted at oomph-lib@maths.man.ac.uk.
24
// LIC//
25
// LIC//====================================================================
26
// Non-inline functions for Poisson elements
27
#include "
benchmark_elements.h
"
28
29
30
namespace
oomph
31
{
32
//======================================================================
33
/// Compute element residual Vector and/or element Jacobian matrix
34
//======================================================================
35
template
<
unsigned
NNODE_1D>
36
void
ShellBenchmarkElement<NNODE_1D>::
37
fill_in_generic_residual_contribution_shell_benchmark
(
38
Vector<double>& residuals)
39
{
40
// Find out how many nodes there are
41
const
unsigned
n_node = nnode();
42
43
// Set up memory for the shape and test functions
44
Shape psi(n_node);
45
DShape dpsidx(n_node, 1);
46
47
// Index at which the poisson unknown is stored
48
const
unsigned
u_nodal_index = 0;
// u_index_shell_benchmark();
49
50
// Set the value of n_intpt
51
const
unsigned
n_intpt = integral_pt()->nweight();
52
53
// Integer to store local equation number
54
int
local_eqn = 0;
55
56
// Get the Poisson ratio
57
double
nu_local = nu();
58
59
// Loop over the integration points
60
for
(
unsigned
ipt = 0; ipt < n_intpt; ipt++)
61
{
62
// Get the integral weight
63
double
w = integral_pt()->weight(ipt);
64
65
// Call the derivatives of the shape and test functions
66
double
J = dshape_eulerian_at_knot(ipt, psi, dpsidx);
67
68
// Premultiply the weights and the Jacobian
69
double
W = w * J;
70
71
// Calculate local values of unknown
72
// Allocate and initialise to zero
73
double
interpolated_u = 0.0;
74
double
interpolated_x = 0.0;
75
double
interpolated_dudx = 0.0;
76
77
// Calculate function value and derivatives:
78
//-----------------------------------------
79
// Loop over nodes
80
for
(
unsigned
l = 0; l < n_node; l++)
81
{
82
// Get the nodal value of the poisson unknown
83
double
u_value = raw_nodal_value(l, u_nodal_index);
84
interpolated_u += u_value * psi(l);
85
interpolated_dudx += u_value * dpsidx(l, 0);
86
interpolated_x += raw_nodal_position(l, 0) * psi(l);
87
}
88
89
// Assign the principal stretches, as well as the J term
90
double
lambda_r = interpolated_dudx;
91
double
lambda_t = interpolated_u / interpolated_x;
92
double
J_vol = lambda_r * lambda_t * lambda_t;
93
double
tmp = 0.5 / (1.0 + nu_local);
94
// Assemble the A term
95
double
A = tmp *
96
(lambda_r * lambda_r - 1.0 +
97
((2.0 * nu_local) / (1.0 - 2.0 * nu_local)) * log(J_vol)) /
98
J_vol;
99
// Assemble B term
100
double
B =
101
tmp * (2.0 / interpolated_u) * (pow(lambda_r / lambda_t, 2.0) - 1.0);
102
103
// Assemble residuals (Jacobian is done by finite
104
// differences)
105
106
// Loop over the test functions
107
for
(
unsigned
l = 0; l < n_node; l++)
108
{
109
// Get the local equation
110
local_eqn = nodal_local_eqn(l, u_nodal_index);
111
// IF it's not a boundary condition
112
if
(local_eqn >= 0)
113
{
114
// Add the contribution
115
residuals[local_eqn] += (-1.0 * A * dpsidx(l, 0) + B * psi(l)) * W;
116
}
117
}
// End of loop over test functions
118
}
// End of loop over integration points
119
}
120
121
122
//======================================================================
123
/// Output function
124
//======================================================================
125
template
<
unsigned
NNODE_1D>
126
void
ShellBenchmarkElement<NNODE_1D>::output
(std::ostream& outfile,
127
const
unsigned
& nplot)
128
{
129
// Vector of local coordinates
130
Vector<double> s(1);
131
132
// Tecplot header info
133
outfile << tecplot_zone_string(nplot);
134
135
// Loop over plot points
136
unsigned
num_plot_points = nplot_points(nplot);
137
for
(
unsigned
iplot = 0; iplot < num_plot_points; iplot++)
138
{
139
// Get local coordinates of plot point
140
get_s_plot(iplot, nplot, s);
141
outfile << interpolated_x(s, 0) <<
" "
;
142
outfile << interpolated_u_shell_benchmark(s) << std::endl;
143
}
144
145
// Write tecplot footer (e.g. FE connectivity lists)
146
write_tecplot_zone_footer(outfile, nplot);
147
}
148
149
//===========================================================================
150
/// Compute the element's residual vector and the (zero) Jacobian matrix.
151
//===========================================================================
152
void
ShellBenchmarkPressureElement::
153
fill_in_generic_residual_contribution_shell_benchmark_pressure
(
154
Vector<double>& residuals)
155
{
156
// Get the pressure
157
double
pressure_local =
pressure
();
158
159
// Get the local equation
160
int
local_eqn = nodal_local_eqn(0, 0);
161
162
// If a Dirichlet condition has not been set
163
if
(local_eqn >= 0)
164
{
165
// Add the contribution
166
residuals[local_eqn] -= pressure_local;
167
}
168
}
169
170
// Instantiate required elements
171
template
class
ShellBenchmarkElement<2>
;
172
template
class
ShellBenchmarkElement<3>
;
173
template
class
ShellBenchmarkElement<4>
;
174
175
}
// namespace oomph
benchmark_elements.h
oomph::ShellBenchmarkElement
A class for elements to solve the 1D radial displacement ODE in the spherical shell compression bench...
Definition
benchmark_elements.h:43
oomph::ShellBenchmarkElement::output
void output(std::ostream &outfile, const unsigned &n_plot)
Output FE representation of soln: x,y,u or x,y,z,u at n_plot^DIM plot points.
Definition
benchmark_elements.cc:126
oomph::ShellBenchmarkElement::fill_in_generic_residual_contribution_shell_benchmark
virtual void fill_in_generic_residual_contribution_shell_benchmark(Vector< double > &residuals)
Compute element residual Vector only (if flag=and/or element Jacobian matrix.
Definition
benchmark_elements.cc:37
oomph::ShellBenchmarkPressureElement::fill_in_generic_residual_contribution_shell_benchmark_pressure
void fill_in_generic_residual_contribution_shell_benchmark_pressure(Vector< double > &residuals)
Compute the element residual vector. flag=1(or 0): do (or don't) compute the Jacobian as well.
Definition
benchmark_elements.cc:153
oomph::ShellBenchmarkPressureElement::pressure
const double & pressure() const
Access function: Poisson ratio.
Definition
benchmark_elements.h:154
oomph
Definition
benchmark_elements.cc:31