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
Installation
Installation guide
Copyright
About
People
Contact/Get involved
Publications
Acknowledgements
Picture show
Go
demo_drivers
interaction
free_boundary_poisson
geom_object_element.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-2023 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
// Demonstrate use of geometric object as GeneralisedElement
27
28
29
// Generic oomph-lib headers
30
#include "generic.h"
31
32
// Circle as generalised element:
33
#include "
circle_as_generalised_element.h
"
34
35
using namespace
std;
36
37
using namespace
oomph
;
38
39
/// ////////////////////////////////////////////////////////////////////
40
/// ////////////////////////////////////////////////////////////////////
41
/// ////////////////////////////////////////////////////////////////////
42
43
44
//======start_of_problem==============================================
45
/// Problem to demonstrate the use of a GeomObject as a
46
/// GeneralisedElement: A geometric object (a Circle) is "upgraded"
47
/// to a GeneralisedElement. The position of the Circle is
48
/// determined by a balance of forces, assuming that the
49
/// Circle is mounted on an elastic spring of specified
50
/// stiffness and loaded by a vertical "load".
51
//====================================================================
52
class
GeomObjectAsGeneralisedElementProblem
:
public
Problem
53
{
54
55
public
:
56
57
/// Constructor
58
GeomObjectAsGeneralisedElementProblem
();
59
60
/// Update the problem specs after solve (empty)
61
void
actions_after_newton_solve
(){}
62
63
/// Update the problem specs before solve (empty)
64
void
actions_before_newton_solve
() {}
65
66
/// Doc the solution
67
void
doc_solution();
68
69
/// Return value of the "load" on the elastically supported ring
70
double
&
load
()
71
{
72
return
*Load_pt->value_pt(0);
73
}
74
75
/// Access to DocInfo object
76
DocInfo&
doc_info
() {
return
Doc_info;}
77
78
private
:
79
80
/// Trace file
81
ofstream
Trace_file
;
82
83
/// Pointer to data item that stores the "load" on the ring
84
Data*
Load_pt
;
85
86
/// Doc info object
87
DocInfo
Doc_info
;
88
89
};
90
91
92
93
94
95
//=============================start_of_problem_constructor===============
96
/// Constructor
97
//========================================================================
98
GeomObjectAsGeneralisedElementProblem::GeomObjectAsGeneralisedElementProblem
()
99
{
100
101
// Set coordinates and radius for the circle
102
double
x_c=0.5;
103
double
y_c=0.0;
104
double
R=1.0;
105
106
// Build GeomObject that's been upgraded to a GeneralisedElement
107
// GeneralisedElement*
108
ElasticallySupportedRingElement* geom_object_element_pt =
109
new
ElasticallySupportedRingElement(x_c,y_c,R);
110
111
// Set the stiffness of the elastic support
112
geom_object_element_pt->k_stiff()=0.3;
113
114
// Build mesh
115
mesh_pt()=
new
Mesh;
116
117
// So far, the mesh is completely empty. Let's add the
118
// one (and only!) GeneralisedElement to it:
119
mesh_pt()->add_element_pt(geom_object_element_pt);
120
121
// Create the load (a Data object with a single value)
122
Load_pt=
new
Data(1);
123
124
// The load is prescribed so its one-and-only value is pinned
125
Load_pt->pin(0);
126
127
// Set the pointer to the Data object that specifies the
128
// load on the ring
129
geom_object_element_pt->set_load_pt(Load_pt);
130
131
// Setup equation numbering scheme.
132
cout <<
"Number of equations: "
<< assign_eqn_numbers() << std::endl;
133
134
// Set output directory
135
Doc_info.set_directory(
"RESLT"
);
136
137
// Open trace file
138
char
filename[100];
139
sprintf(filename,
"%s/trace.dat"
,Doc_info.directory().c_str());
140
Trace_file.open(filename);
141
Trace_file <<
"VARIABLES=\"load\",\"y<sub>circle</sub>\""
<< std::endl;
142
143
}
// end of constructor
144
145
146
147
148
//===========================start_of_doc_solution========================
149
/// Doc the solution in tecplot format.
150
//========================================================================
151
void
GeomObjectAsGeneralisedElementProblem::doc_solution
()
152
{
153
154
ofstream some_file;
155
char
filename[100];
156
157
// Number of plot points
158
unsigned
npts=100;
159
160
// Lagrangian coordinate and position vector (both as vectors)
161
Vector<double> zeta(1);
162
Vector<double> r(2);
163
164
// Output solution
165
sprintf(filename,
"%s/soln%i.dat"
,Doc_info.directory().c_str(),
166
Doc_info.number());
167
some_file.open(filename);
168
for
(
unsigned
i=0;i<npts;i++)
169
{
170
zeta[0]=2.0*MathematicalConstants::Pi*double(i)/double(npts-1);
171
static_cast<
ElasticallySupportedRingElement*
>
(mesh_pt()->element_pt(0))->
172
position(zeta,r);
173
some_file << r[0] <<
" "
<< r[1] << std::endl;
174
}
175
some_file.close();
176
177
178
// Write "load" and vertical position of the ring's centre
179
Trace_file
180
<<
static_cast<
ElasticallySupportedRingElement*
>
(
181
mesh_pt()->element_pt(0))->load()
182
<<
" "
183
<<
static_cast<
ElasticallySupportedRingElement*
>
(
184
mesh_pt()->element_pt(0))->y_c()
185
<<
" "
186
<< std::endl;
187
188
}
// end of doc_solution
189
190
191
192
193
194
195
196
197
/// /////////////////////////////////////////////////////////////////////
198
/// /////////////////////////////////////////////////////////////////////
199
/// /////////////////////////////////////////////////////////////////////
200
201
202
203
204
205
//===============start_of_driver==========================================
206
/// Driver
207
//========================================================================
208
int
main
()
209
{
210
211
// Set up the problem
212
GeomObjectAsGeneralisedElementProblem
problem;
213
214
// Initial value for the load
215
problem.
load
()=-0.3;
216
217
// Loop for different loads
218
//-------------------------
219
220
// Number of steps
221
unsigned
nstep=5;
222
223
// Increment in load
224
double
dp=0.6/double(nstep-1);
225
226
for
(
unsigned
istep=0;istep<nstep;istep++)
227
{
228
// Solve/doc
229
problem.newton_solve();
230
problem.
doc_solution
();
231
232
//Increment counter for solutions
233
problem.
doc_info
().number()++;
234
235
// Change load on ring
236
problem.
load
()+=dp;
237
}
238
239
}
// end of driver
240
241
circle_as_generalised_element.h
GeomObjectAsGeneralisedElementProblem
//////////////////////////////////////////////////////////////////// ////////////////////////////////...
Definition:
geom_object_element.cc:53
GeomObjectAsGeneralisedElementProblem::actions_before_newton_solve
void actions_before_newton_solve()
Update the problem specs before solve (empty)
Definition:
geom_object_element.cc:64
GeomObjectAsGeneralisedElementProblem::doc_info
DocInfo & doc_info()
Access to DocInfo object.
Definition:
geom_object_element.cc:76
GeomObjectAsGeneralisedElementProblem::doc_solution
void doc_solution()
Doc the solution.
Definition:
geom_object_element.cc:151
GeomObjectAsGeneralisedElementProblem::load
double & load()
Return value of the "load" on the elastically supported ring.
Definition:
geom_object_element.cc:70
GeomObjectAsGeneralisedElementProblem::Doc_info
DocInfo Doc_info
Doc info object.
Definition:
geom_object_element.cc:87
GeomObjectAsGeneralisedElementProblem::Load_pt
Data * Load_pt
Pointer to data item that stores the "load" on the ring.
Definition:
geom_object_element.cc:84
GeomObjectAsGeneralisedElementProblem::GeomObjectAsGeneralisedElementProblem
GeomObjectAsGeneralisedElementProblem()
Constructor.
Definition:
geom_object_element.cc:98
GeomObjectAsGeneralisedElementProblem::Trace_file
ofstream Trace_file
Trace file.
Definition:
geom_object_element.cc:81
GeomObjectAsGeneralisedElementProblem::actions_after_newton_solve
void actions_after_newton_solve()
Update the problem specs after solve (empty)
Definition:
geom_object_element.cc:61
main
int main()
///////////////////////////////////////////////////////////////////// ///////////////////////////////...
Definition:
geom_object_element.cc:208
oomph
Definition:
circle.h:34