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
Get it
Installation guide
Get code from subversion repository
Get code as tar file
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// Version 1.0; svn revision $LastChangedRevision$
7
//LIC//
8
//LIC// $LastChangedDate$
9
//LIC//
10
//LIC// Copyright (C) 2006-2016 Matthias Heil and Andrew Hazel
11
//LIC//
12
//LIC// This library is free software; you can redistribute it and/or
13
//LIC// modify it under the terms of the GNU Lesser General Public
14
//LIC// License as published by the Free Software Foundation; either
15
//LIC// version 2.1 of the License, or (at your option) any later version.
16
//LIC//
17
//LIC// This library is distributed in the hope that it will be useful,
18
//LIC// but WITHOUT ANY WARRANTY; without even the implied warranty of
19
//LIC// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20
//LIC// Lesser General Public License for more details.
21
//LIC//
22
//LIC// You should have received a copy of the GNU Lesser General Public
23
//LIC// License along with this library; if not, write to the Free Software
24
//LIC// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25
//LIC// 02110-1301 USA.
26
//LIC//
27
//LIC// The authors may be contacted at oomph-lib@maths.man.ac.uk.
28
//LIC//
29
//LIC//====================================================================
30
// Demonstrate use of geometric object as GeneralisedElement
31
32
33
// Generic oomph-lib headers
34
#include "generic.h"
35
36
// Circle as generalised element:
37
#include "
circle_as_generalised_element.h
"
38
39
using namespace
std
;
40
41
using namespace
oomph
;
42
43
///////////////////////////////////////////////////////////////////////
44
///////////////////////////////////////////////////////////////////////
45
///////////////////////////////////////////////////////////////////////
46
47
48
//======start_of_problem==============================================
49
/// Problem to demonstrate the use of a GeomObject as a
50
/// GeneralisedElement: A geometric object (a Circle) is "upgraded"
51
/// to a GeneralisedElement. The position of the Circle is
52
/// determined by a balance of forces, assuming that the
53
/// Circle is mounted on an elastic spring of specified
54
/// stiffness and loaded by a vertical "load".
55
//====================================================================
56
class
GeomObjectAsGeneralisedElementProblem
:
public
Problem
57
{
58
59
public
:
60
61
/// Constructor
62
GeomObjectAsGeneralisedElementProblem
();
63
64
/// Update the problem specs after solve (empty)
65
void
actions_after_newton_solve
(){}
66
67
/// Update the problem specs before solve (empty)
68
void
actions_before_newton_solve
() {}
69
70
/// Doc the solution
71
void
doc_solution();
72
73
/// Return value of the "load" on the elastically supported ring
74
double
&
load
()
75
{
76
return
*Load_pt->value_pt(0);
77
}
78
79
/// Access to DocInfo object
80
DocInfo&
doc_info
() {
return
Doc_info;}
81
82
private
:
83
84
/// Trace file
85
ofstream
Trace_file
;
86
87
/// \short Pointer to data item that stores the "load" on the ring
88
Data*
Load_pt
;
89
90
/// Doc info object
91
DocInfo
Doc_info
;
92
93
};
94
95
96
97
98
99
//=============================start_of_problem_constructor===============
100
/// Constructor
101
//========================================================================
102
GeomObjectAsGeneralisedElementProblem::GeomObjectAsGeneralisedElementProblem
()
103
{
104
105
// Set coordinates and radius for the circle
106
double
x_c=0.5;
107
double
y_c=0.0;
108
double
R=1.0;
109
110
// Build GeomObject that's been upgraded to a GeneralisedElement
111
// GeneralisedElement*
112
ElasticallySupportedRingElement
* geom_object_element_pt =
113
new
ElasticallySupportedRingElement
(x_c,y_c,R);
114
115
// Set the stiffness of the elastic support
116
geom_object_element_pt->
k_stiff
()=0.3;
117
118
// Build mesh
119
mesh_pt()=
new
Mesh;
120
121
// So far, the mesh is completely empty. Let's add the
122
// one (and only!) GeneralisedElement to it:
123
mesh_pt()->add_element_pt(geom_object_element_pt);
124
125
// Create the load (a Data object with a single value)
126
Load_pt=
new
Data(1);
127
128
// The load is prescribed so its one-and-only value is pinned
129
Load_pt->pin(0);
130
131
// Set the pointer to the Data object that specifies the
132
// load on the ring
133
geom_object_element_pt->
set_load_pt
(Load_pt);
134
135
// Setup equation numbering scheme.
136
cout <<
"Number of equations: "
<< assign_eqn_numbers() << std::endl;
137
138
// Set output directory
139
Doc_info.set_directory(
"RESLT"
);
140
141
// Open trace file
142
char
filename[100];
143
sprintf(filename,
"%s/trace.dat"
,Doc_info.directory().c_str());
144
Trace_file.open(filename);
145
Trace_file <<
"VARIABLES=\"load\",\"y<sub>circle</sub>\""
<< std::endl;
146
147
}
// end of constructor
148
149
150
151
152
//===========================start_of_doc_solution========================
153
/// Doc the solution in tecplot format.
154
//========================================================================
155
void
GeomObjectAsGeneralisedElementProblem::doc_solution
()
156
{
157
158
ofstream some_file;
159
char
filename[100];
160
161
// Number of plot points
162
unsigned
npts=100;
163
164
// Lagrangian coordinate and position vector (both as vectors)
165
Vector<double> zeta(1);
166
Vector<double> r(2);
167
168
// Output solution
169
sprintf(filename,
"%s/soln%i.dat"
,Doc_info.directory().c_str(),
170
Doc_info.number());
171
some_file.open(filename);
172
for
(
unsigned
i=0;i<npts;i++)
173
{
174
zeta[0]=2.0*MathematicalConstants::Pi*double(i)/double(npts-1);
175
static_cast<
ElasticallySupportedRingElement
*
>
(mesh_pt()->element_pt(0))->
176
position(zeta,r);
177
some_file << r[0] <<
" "
<< r[1] << std::endl;
178
}
179
some_file.close();
180
181
182
// Write "load" and vertical position of the ring's centre
183
Trace_file
184
<<
static_cast<
ElasticallySupportedRingElement
*
>
(
185
mesh_pt()->element_pt(0))->load()
186
<<
" "
187
<<
static_cast<
ElasticallySupportedRingElement
*
>
(
188
mesh_pt()->element_pt(0))->y_c()
189
<<
" "
190
<< std::endl;
191
192
}
// end of doc_solution
193
194
195
196
197
198
199
200
201
////////////////////////////////////////////////////////////////////////
202
////////////////////////////////////////////////////////////////////////
203
////////////////////////////////////////////////////////////////////////
204
205
206
207
208
209
//===============start_of_driver==========================================
210
/// Driver
211
//========================================================================
212
int
main
()
213
{
214
215
// Set up the problem
216
GeomObjectAsGeneralisedElementProblem
problem;
217
218
// Initial value for the load
219
problem.
load
()=-0.3;
220
221
// Loop for different loads
222
//-------------------------
223
224
// Number of steps
225
unsigned
nstep=5;
226
227
// Increment in load
228
double
dp=0.6/double(nstep-1);
229
230
for
(
unsigned
istep=0;istep<nstep;istep++)
231
{
232
// Solve/doc
233
problem.newton_solve();
234
problem.
doc_solution
();
235
236
//Increment counter for solutions
237
problem.
doc_info
().number()++;
238
239
// Change load on ring
240
problem.
load
()+=dp;
241
}
242
243
}
// end of driver
244
245
GeomObjectAsGeneralisedElementProblem::Load_pt
Data * Load_pt
Pointer to data item that stores the "load" on the ring.
Definition:
geom_object_element.cc:88
oomph::ElasticallySupportedRingElement::set_load_pt
void set_load_pt(Data *load_pt)
Set pointer to Data object that specifies the "load" on the ElasticallySupportedRingElement.
Definition:
circle_as_generalised_element.h:102
oomph::ElasticallySupportedRingElement::k_stiff
double & k_stiff()
Access function for the spring stiffness.
Definition:
circle_as_generalised_element.h:148
std
main
int main()
Driver.
Definition:
geom_object_element.cc:212
GeomObjectAsGeneralisedElementProblem::Doc_info
DocInfo Doc_info
Doc info object.
Definition:
geom_object_element.cc:91
GeomObjectAsGeneralisedElementProblem::actions_after_newton_solve
void actions_after_newton_solve()
Update the problem specs after solve (empty)
Definition:
geom_object_element.cc:65
GeomObjectAsGeneralisedElementProblem::actions_before_newton_solve
void actions_before_newton_solve()
Update the problem specs before solve (empty)
Definition:
geom_object_element.cc:68
oomph
Definition:
circle.h:37
GeomObjectAsGeneralisedElementProblem::Trace_file
ofstream Trace_file
Trace file.
Definition:
geom_object_element.cc:85
GeomObjectAsGeneralisedElementProblem::doc_solution
void doc_solution()
Doc the solution.
Definition:
geom_object_element.cc:155
GeomObjectAsGeneralisedElementProblem::GeomObjectAsGeneralisedElementProblem
GeomObjectAsGeneralisedElementProblem()
Constructor.
Definition:
geom_object_element.cc:102
circle_as_generalised_element.h
GeomObjectAsGeneralisedElementProblem::doc_info
DocInfo & doc_info()
Access to DocInfo object.
Definition:
geom_object_element.cc:80
GeomObjectAsGeneralisedElementProblem
Definition:
geom_object_element.cc:56
GeomObjectAsGeneralisedElementProblem::load
double & load()
Return value of the "load" on the elastically supported ring.
Definition:
geom_object_element.cc:74
oomph::ElasticallySupportedRingElement
GeneralCircle "upgraded" to a GeneralisedElement: Circular ring whose position is given by The ring...
Definition:
circle_as_generalised_element.h:59