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
poisson
fish_poisson2
fish_domain.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-2024 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
/// Driver code for mucking around with GeomObjects, MacroElements
27
/// and Domains
28
29
// Generic oomph-lib headers
30
#include "generic.h"
31
32
// The fish domain
33
#include "meshes/fish_domain.h"
34
35
using namespace
std;
36
37
using namespace
oomph;
38
39
//=======================start_of_unit_circle==============================
40
/// Unit circle in 2D, centred at the origin, parametrised by a single
41
/// Lagrangian coordinate, the polar angle.
42
//=========================================================================
43
class
UnitCircle
:
public
GeomObject
44
{
45
46
public
:
47
48
/// Constructor: Pass the number of Lagrangian
49
/// and Eulerian coordinates to the constructor of the
50
/// GeomObject base class.
51
UnitCircle
() : GeomObject(1,2) {}
52
53
/// Destructor -- emtpy
54
virtual
~UnitCircle
(){}
55
56
/// Position vector, r, to the point on the circle identified by
57
/// its 1D Lagrangian coordinate, xi (passed as a 1D Vector):
58
void
position
(
const
Vector<double>& xi, Vector<double>& r)
const
59
{
60
// Eulerian position vector
61
r[0] = cos(xi[0]);
62
r[1] = sin(xi[0]);
63
}
64
65
66
/// Position vector, r, to the point on the circle identified by
67
/// its 1D Lagrangian coordinate, xi (passed as a 1D Vector) at discrete time
68
/// level t (t=0: present; t>0: previous). The shape of the object
69
/// is not time-dependent, therefore we forward this call to the
70
/// steady version.
71
void
position
(
const
unsigned
& t,
const
Vector<double>& xi,
72
Vector<double>& r)
const
73
{
74
position(xi,r);
75
}
76
77
};
// end of unit circle class
78
79
80
81
82
83
84
//===================================================================
85
/// Driver code for mucking around with GeomObjects, MacroElements
86
/// and domains
87
//===================================================================
88
int
main
()
89
{
90
91
92
// Play around with a GeomObject
93
//------------------------------
94
95
// Create a unit circle
96
UnitCircle
unit_circle;
97
98
// Plot:
99
ofstream circle_file(
"unit_circle.dat"
);
100
101
// Number of plot points
102
unsigned
nplot=50;
103
104
// 1D vector for the Lagrangian coordinate
105
Vector<double> s(1);
106
107
// 2D vector for the Eulerian position
108
Vector<double> r(2);
109
110
for
(
unsigned
i=0;i<nplot;i++)
111
{
112
// Lagrangian coordinate at plot point
113
s[0]=2.0*MathematicalConstants::Pi*double(i)/double(nplot-1);
114
115
// Get Eulerian position vector from GeomObject:
116
unit_circle.
position
(s,r);
117
118
// Plot
119
circle_file << r[0] <<
" "
<< r[1] << std::endl;
120
}
121
122
123
// Close output file
124
circle_file.close();
125
126
127
128
129
130
// Build a FishDomain and plot it
131
//-------------------------------
132
133
134
// Create the fish's back as a circle of radius 1, centred at (0.5,0.0)
135
double
x_c=0.5;
136
double
y_c=0.0;
137
double
r_back=1.0;
138
GeomObject* back_pt=
new
Circle(x_c,y_c,r_back);
139
140
141
// Start and end coordinates of the fish back
142
double
s_nose=2.6;
143
double
s_tail=0.4;
144
145
// Create the domain
146
Domain* domain_pt=
new
FishDomain(back_pt,s_nose,s_tail);
147
148
149
// Plot the domain
150
151
// Number of plot points in each coordinate direction.
152
unsigned
npts=10;
153
154
// Output domain (= plot its macro elements) and the macro element boundaries
155
ofstream domain_file(
"fish_domain.dat"
);
156
domain_pt->output(domain_file,npts);
157
domain_pt->output_macro_element_boundaries(domain_file,npts);
158
domain_file.close();
159
160
161
}
UnitCircle
Unit circle in 2D, centred at the origin, parametrised by a single Lagrangian coordinate,...
Definition:
fish_domain.cc:44
UnitCircle::UnitCircle
UnitCircle()
Constructor: Pass the number of Lagrangian and Eulerian coordinates to the constructor of the GeomObj...
Definition:
fish_domain.cc:51
UnitCircle::~UnitCircle
virtual ~UnitCircle()
Destructor – emtpy.
Definition:
fish_domain.cc:54
UnitCircle::position
void position(const Vector< double > &xi, Vector< double > &r) const
Position vector, r, to the point on the circle identified by its 1D Lagrangian coordinate,...
Definition:
fish_domain.cc:58
UnitCircle::position
void position(const unsigned &t, const Vector< double > &xi, Vector< double > &r) const
Position vector, r, to the point on the circle identified by its 1D Lagrangian coordinate,...
Definition:
fish_domain.cc:71
main
int main()
Driver code for mucking around with GeomObjects, MacroElements and domains.
Definition:
fish_domain.cc:88