Overture  Version 25
FilamentMapping.h
Go to the documentation of this file.
1 //
2 // Filament Mapping August 7, 2000
3 // **pf
4 // $Id: FilamentMapping.h,v 1.15 2011/06/13 20:09:16 henshaw Exp $
5 
6 // March 23, 2001 **pf
7 // * Adding the time derivatives code
8 // 1) for x_t etc
9 // 2) compute n_t, n_tt etc
10 
11 // Feb 26, 2001 **pf
12 //
13 // I broke 'updateFilamentAndGrid' & the whole lazy evaluator.
14 // --> reason:
15 // * the old 'filamentNeedsUpdate' induced a call to
16 // to evaluateAtTime.
17 // * After Jan2001, I only set 'geometricDataNeedsUpdate',
18 // which did not update the centerline
19 // -- for generic dynamics, outside code would change the centerline,
20 // and set 'geometricDataNeedsUpdate'
21 // -- maybe I should, as next step, generate the filament motion
22 // outside & pass it in as the centerline.
23 // -- NEW FLAG: prescribedShapeNeedsUpdate
24 // --> like the old 'filamentNeeds...', but no memory updates?!?
25 //
26 
27 // Jan 2001 rehash off the FilamentMapping code **pf
28 // * new flag 'geometricDataNeedsUpdate' replaces 'filamentNeedsUpdate'
29 // * Bdry & motion type enums are renamed/reorganized:
30 // > The filament can be open, closed(=periodic) or a
31 // user defined curve
32 // ==> enum FilamentType
33 //
34 // > The boundary of the physical filament (in the 'fluid domain')
35 // can be
36 // ** THICK_FILAMENT -- only for OPEN_FILAMENTS (or user defined,
37 // non, periodic centerlines);
38 // .. Make a thick filament, which is a periodic curve.
39 // ** ONE_SIDED_FILAMENT -- for OPEN or CLOSED filaments:
40 // .. Use when fluid is only on one side of the filament.
41 // .. E.g. closed filament = fluid bubble in air (where air
42 // has no dynamics; or a (nondynamic) airbubble in a fluid.
43 // .. E.g. 2, an open filament = long bubble moving into a
44 // a tube, symmetric interface, a la Reinelt & Saffman.
45 // ** THIN_TWO_SIDED -- not available yet.
46 // requires using H-grids, for, e.g. the elastic filament.
47 // * Removed fluff
48 // > realArray x0 -- not needed, was supposed to have centerline=xFilament
49 //
50 // ADD 9/28/00 **pf
51 // "Enter the tangent of the line of translation"
52 // "Enter the speed of translation"
53 //
54 
55 #ifndef FILAMENT_MAPPING_H
56 #define FILAMENT_MAPPING_H
57 
58 #include "GenericDataBase.h"
59 #include "Mapping.h"
60 #include "StretchMapping.h"
62 // AP #include "Display.h"
63 #include "display.h"
64 
65 //..Forward definitions
66 class HyperbolicMapping;
67 class SplineMapping;
69 //class DeformingGridGenerationInformation;
70 //class TravelingWaveParameters;
71 class FilamentData; //used to store app. dependent data 6/28/01
72 
73 //..aux data
74 const int maxFilamentStretchingLayers = 4; //not so great to have this here. XXPF
76 public:
84 
87 
88  void initialize();
89  bool isUsed();
90  void setNumberOfLayers( int numLayers_);
91 
92  void setAllLayerParameters( real a, real b );
93  void setLayerParameters( int i, real a, real b, real c );
94  void getLayerParameters( int i, real &a, real &b, real &c );
95 
97  void useStretching( bool stretchFlag_ = true );
99  void map( const realArray &r, realArray &x );
100  int put( GenericDataBase & dir, const aString & name) const;
101  int get( GenericDataBase & dir, const aString & name);
102 
103 private: // these are not to be used
105  FilamentStretching& operator=(const FilamentStretching&X);
106 };
107 
108 //
109 // FILAMENT class
110 //
111 
112 class FilamentMapping : public Mapping
113 {
114 
115  private:
116  aString className;
117  // Private data representing the Filament
118 
119  public:
120 
122  int nEndPoints = 7,
123  real thickness = 0.04,
124  real endRadius = 0.02
125  );
126 
128 
129  //---------------------STANDARD MAPPING INTERFACE
130  //Copy constructors
131  FilamentMapping( const FilamentMapping &, const CopyType copyType=DEEP );
132  FilamentMapping & operator =( const FilamentMapping & xmap00 );
133 
134  void map( const realArray & r, realArray & x,
137 
138  void basicInverse( const realArray & x, realArray & r, realArray & rx, MappingParameters & params );
139 
140  virtual int get( const GenericDataBase & dir, const aString & name);
141  virtual int put( GenericDataBase & dir, const aString & name) const;
142 
143  Mapping *make( const aString & mappingClassName );
144 
145  aString getClassName() const;
146 
147  int update( MappingInformation & mapInfo );
148 
149  //
150  //------------------Filament functionality
151  //
152 
153  void replaceHyperbolicMapping( HyperbolicMapping *pNewHyper );
154  void evaluateAtTime( real time00 );
155  void evaluateSurfaceAtTime( real time0, SplineMapping *curvePosition);
156 
157  void evaluateCenterLineAtTime( real time00 );
158 
159  //..NEW -- for getting boundary velocity/acceleration **pf
162  void getCorePoints( realArray &x00);
163  void getCoreDerivative( realArray &xr00);
164  void setupTimeDerivatives(realArray & x_t, realArray & x_tt,
165  realArray &xr, realArray &xr_t, realArray & xr_tt);
166  void getSurfacePoints( realArray &xSurface );
167  void getSurfaceVelocity( realArray &coreVelocity, realArray & surfaceVelocity );
168  void getSurfaceAcceleration( realArray &coreAcceleration, realArray & surfaceAcceleration );
169 
170  //n/a: void generate(); // update filament & regenerate HyperbolicMapping?
171 
172  //..Public
175  aString *pMappingRename = NULL);
176 
177  //..Filament & Grid types
178  // * Filaments are open or closed(=periodic). Or, a given centerline.
179  // * the boundary can be thick, one-sided, or thin(=H-grid)
180  // * the motion can be RIGID, TRAVELINGWAVE or TRANSLATING
181  //
185  USER_DEFINED_CURVE_FILAMENT// was: USER_DEFINED_CENTER_LINE
186  };
187 
192  };
193 
199  };
200 
201  //.... User access routines to parameters: changing
202  //.... requires the filament to be updated
203  //....
204 
205  void setOffset( real xOffset=0.,
206  real yOffset=0.);
207 
208  void setLength( real length00);
209 
210  void setTravelingWaveParameters( real length00=1., // length
211  real aParam00=0.1, // amplitude param A
212  real bParam00=0.05, // - "" - B
213  real omega00=1.2, // time freq.
214  real knum00=1.2 // space freq
215  );
216 
217  void setTranslatingMotionParameters( real tangX, real tangY, real velo);
218  void getTranslatingMotionParameters( real &tangX, real &tangY, real &velo);
219 
220  void setFilamentTime( real newTime );
221  void setFilamentTimeOffset( real newTime );
222  void setThicknessAndEndRadius( real thick00, real endRadius00);
223 
224  void setNumberOfFilamentPoints( int nFilamentPoints00, int nSplinePoints ); //equal by default
225  void setNumberOfFilamentPoints( int nFilamentPoints00);
227 
228  void setNumberOfEndPoints( int nEndPoints00=5 );
229  void setNumberOfThickSplinePoints( int nThickFilamPts );
231 
233  int getDefaultNumberOfThickFilamentPoints( int nFilam, int nEnd );
234  //void setDefaultNumberOfThickFilamentPoints( );
235 
236  //old: void setMotionType( PrescribedMotionType motionType00);
237  void setMotionType( BoundaryMotionType motionType00);
238  void setFilamentType( FilamentType filamentType00);
239  void setFilamentBoundaryType(FilamentBoundaryType filamBdryType00);
240  void setHyperbolicMappingParameters( real distanceToMarch00 = 0.3,
241  real dissipation00 = 0.2);
242 
243  void setHyperbolicGridDimensions( int gridDimension1_, int gridDimension2_,
244  int gridGenDimension1_, int gridGenDimension2_);
245 
246  void setHyperbolicGridInfo();
247  void getHyperbolicGridInfo();
248 
252 
253  //--PARAMETERS -- set by the user
255  int nSplinePoints; // >= nFilamPts
256 
259 
261  real xOffset, yOffset; // filament leading edge
262  real sXDirection, sYDirection; // tang. direction of lead. edge
263 
264  real thickness; // thickness
265  real endRadius; // radius of the end
266 
267  FilamentStretching stretching; // container for stretching data
268 
269  int debug; // DEBUG level
270 
271  real timeOffset; // tFilament = tcomp-timeOffset
272 
273  //
274  // STATUS flags -- these are used for LAZY evaluation of the filament,
275  // and to avoid calling the HyperbMapping unless necessary **pf
276  // **outline:
277  // > memory is updated --> isFilamentInitialized
278  // > centerline changed, find normals etc --> geomDataNeedsUpdate
279  // > flow boundary changed --> bodyFittedMapNeedsUpdate
280  // > trav wave params changed, or user
281  // defined centerline changed --> centerLineNeedsUpdate
282  //
283  // N.B. setting one implies others
284  // ** centerLine==true-->geomData==true-->bodyFitted==true
285 
286  bool isFilamentInitialized; // set to FALSE by initializeFilamentStorage()
287  bool geometricDataNeedsUpdate; // set to FALSE by computeGeometricData()
288  bool bodyFittedMappingNeedsUpdate; // params for HyperbMapping have changed
289 
290  bool centerLineNeedsUpdate; // set to FALSE by evaluateAtTime()
291 
293 
294  //..FILAMENT DATA
295 // enum FilamentType {
296 // OPEN_FILAMENT,
297 // CLOSED_FILAMENT,
298 // USER_DEFINED_CURVE_FILAMENT// was: USER_DEFINED_CENTER_LINE
299 // };
300 
301 // enum FilamentBoundaryType {
302 // THICK_FILAMENT_BOUNDARY,
303 // ONE_SIDED_FILAMENT_BOUNDARY,
304 // THIN_TWO_SIDED_FILAMENT_BOUNDARY
305 // };
306 
307 // enum BoundaryMotionType {
308 // NO_MOTION,
309 // RIGID_BODY_MOTION,
310 // TRAVELING_WAVE_MOTION,
311 // TRANSLATING_MOTION
312 // };
313 
314 
315  //....Closed filament data
316  // =OPEN_FILAMENT, CLOSED_FILAMENT, USER_DEFINED_CENTER_LINE
317  //enum BoundaryMotionType {
318  // NO_MOTION,
319  // DESCRIBED_BY_CENTERLINE_MOTION,
320  // RIGID_BODY_MOTION,
321  // TRAVELING_WAVE_MOTION
322  // TRANSLATING_MOTION /* NEW -- add the functionality for this */
323  //};
327 
328  //....Traveling wave parameters
329  real aTravelingWaveAmplitude, // amplitude parameters
331  real timeFrequencyTravelingWave, // time & space freq.
333  real timeForFilament; // eval. filament at this time
334 
335 
340 
341  //....Rigid body motion data
342  real xMotionDirection, yMotionDirection; // direction of movement
343  real motionVelocity; // speed of movement
347 
348  //..Working Data
350  realArray sr; // arc-length deriv.
352 
353  //..Centerline = user defined core from which filament is formed
354  Mapping *pUserDefinedCoreCurve; // was: *pCenterLineMapping;
355 
356  //REPRESENTATION as splines & normal/tang vecs
357  SplineMapping *pFilament; // The filament=Core
358 
359  //..Thick Filament = bdry with fluid
360  SplineMapping *pThickFilament; // bdry with fluid
361  //int nTotalThickFilamentPoints; // replaced by a function
362 
363  //POSITION
364  realArray normalVector, tangentVector; // Normal & Tangent
365  realArray xFilament; // filament (x,y) values
367 
369 
370  //POSITION etc for the thick filament
371 
372  //realArray x0; // the centerline? NOT USED?
373 
374  realArray xTop,xBottom; // Pieces of the thick filam.
376 
377  realArray xThickFilament; // All of thickFilam->to Spline
378 
379  //
380  //-------------DeformingGrid generator--Body fitted mapping
381  //
382  int numberOfDimensions; // always =2 (i.e. 2D only)
384 
385  Mapping *getSurfaceForHyperbolicMap(); // return the surface curve
386  // This is =pThickFilament for thick filam,
387  // and =pFilament for one-sided interfaces
388  //
389 
390 
391 
392  //
393  //--------------INTERFACE TO THE FILAMENT
394  //
395  void constructor( int nFilamentPoints00,
396  real thickness00,
397  real endRadius00 );
398 
399  //void constructor( int nFilamentPoints00, int nEndPoints00, // nEndPoints not used anymore
400  // real thickness00, real endRadius00 );
401 
402 
404 
406  void initializeBodyFittedMapping( Mapping *pSurface);
408 
409  bool updateFilamentAndGrid();
410 
413  void getParametrization( realArray & r00 );
414 
415  void computeGeometricData();
416  void computeThickFilament();
417 
418 
419  void setCenterLineMapping( Mapping *pMapping );
420 
421  void displayParameters();
422 
423  //STRETCHING interface
425  int numberOfLayers=2, bool stretchFlag = true );
426 
427  void getStretchingParameters( int i, real &a, real &b, real &c );
428  void setStretchingParameters( int i, real a, real b, real c );
429 
430  //ENDPOINTS & the smooth end computer
432  void setLeadingEndNumberOfPoints( int jj );
434  void setTrailingEndNumberOfPoints( int jj );
435  void setEndPointScaling( real leadingXtra, real trailingXtra );
437  void computeDrFlatSmoothSpacing( real dr00, real sr00, real thickness00,
438  real xtraScaling, int & numberOfEndPoints);
439  void computeFlatSmoothSpacing( real endSpacing, real thickness00,
440  real xtraScaling, int & numberOfEndPoints );
441  //DEBUG DATA
442 // *AP* Display *pDisplay;
443  //realArray xDebug;
444 
445  //--USER DEFINED CENTERLINE
447  real t, realArray & r,
448  realArray & x, realArray & xr );
449 
450  //--RIGID BODY DYNAMICS
451 
453  real xOffset00, real yOffset00,
454  real &xNew, real &yNew,
455  real &xNew_t, real &yNew_t,
456  real &xNew_tt, real &yNew_tt);
457 
458  // ..not available yet
459 
460  //--TRAVELING WAVE DYNAMICS
461 
462  //..parameters -- OBSOLETE, not used..
463  // TravelingWaveParameters *pTravelingWaveData;
465 
466  //
467  // N.B: choose wavespeed = fluid speed = -1
468  // * HENCE omega/knum = 1 is appropriate
469  // * increase space freq (=knum) by 1.2 to make it wigglier
470  // * therefore omega = 1.2
471  // (choosing knum=2 with sparse grid is too wiggly)
472  //
473 
475  realArray & x, realArray & xr );
476 
478  realArray & x, realArray & xr,
479  real xOffset00, real yOffset00);
480 
482  real tcomp, realArray & r00,
483  realArray & x00, realArray &xr00,
484  realArray & x_t, realArray &x_tt,
485  realArray & xr_t, realArray &xr_tt,
486  const real xOffset00=0., const real yOffset00 =0.,
487  const real xOffset_t=0., const real yOffset_t =0.,
488  const real xOffset_tt=0., const real yOffset_tt=0.);
489 
491  realArray &xr00, realArray &xr_t, realArray &xr_tt,
492  realArray &n_t, realArray &s_t,
493  realArray &n_tt, realArray &s_tt);
494 
495  void computeCircularFilament( real tcomp, realArray & r00,
496  realArray & x00, realArray &xr00,
497  real xOffset00 =0., real yOffset00=0. );
498 
499 
500  void getPerpendicular( const realArray &x, realArray &out );
501  void dotProduct( const realArray &x, const realArray &y, realArray &out);
503 
504  void saveCurve( const realArray &curve, const aString &filename );
505 
506 private: // utilities for building leading/trailing end
507  void quintic( const real dtheta, const real f0, const real f1,
508  const real df0, const real df1,
509  const real d2f0, const real d2f1,
510  const realArray & theta, realArray &p);
511 
512  void cubic( const real dtheta, const real f0, const real f1,
513  const real df0, const real df1,
514  const realArray & theta, realArray &p, realArray &dp );
515  void cubic( const real dtheta, const real f0, const real f1,
516  const real df0, const real df1,
517  realArray & theta, realArray &p);
518 
519  void getCurveEdgeData( const realArray & xCurve,
520  int iEdge, int iOffset, const real b,
521  real & dxBase, real & dyBase,
522  real & dx2Base, real & dy2Base,
523  real & curv, real &sr0);
524  void getCurveEdgeData( const realArray & xCurve,
525  int iEdge, int iOffset, const real b,
526  real & dxBase, real & dyBase,
527  real & dx2Base, real & dy2Base,
528  real & curv, real &sr0,
529  real & curvBase1, real &curvBase2);
530 
531  real getEdgeSpacing( const realArray &x, int iEdge, int iOffset);
532 
533 private:
534 
535  //
536  // Virtual member functions used only through class ReferenceCounting:
537  //
538  virtual ReferenceCounting& operator=(const ReferenceCounting& xmap)
539  { return operator=( (FilamentMapping &)xmap); }
540  virtual void reference( const ReferenceCounting& xmap)
541  { reference( (FilamentMapping &)xmap); }
542  virtual ReferenceCounting* virtualConstructor( const CopyType ct = DEEP )
543  const
544  { return ::new FilamentMapping(*this, ct); }
545 
546 };
547 
548 #endif