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