Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Attributes | Friends | List of all members
Nektar::NekMeshUtils::OptiFace Class Reference

#include <OptimiseFunctions.h>

Inheritance diagram for Nektar::NekMeshUtils::OptiFace:
Inheritance graph
[legend]
Collaboration diagram for Nektar::NekMeshUtils::OptiFace:
Collaboration graph
[legend]

Public Member Functions

 OptiFace (Array< OneD, Array< OneD, NekDouble > > a, map< pair< int, int >, NekDouble > w, set< pair< int, int > > sp, CADSurfSharedPtr su)
 
 ~OptiFace ()
 
NekDouble F (Array< OneD, NekDouble > xitst)
 
DNekMat dF (Array< OneD, NekDouble > xitst)
 
Array< OneD, NekDoubleGetxi ()
 
Array< OneD, NekDoubleGetli ()
 
Array< OneD, NekDoubleGetui ()
 
void Update (Array< OneD, NekDouble > xinew)
 
Array< OneD, Array< OneD,
NekDouble > > 
GetSolution ()
 
- Public Member Functions inherited from Nektar::NekMeshUtils::OptiObj
 OptiObj ()
 
virtual ~OptiObj ()
 

Private Attributes

CADSurfSharedPtr s
 
map< pair< int, int >, NekDoublez
 
set< pair< int, int > > spring
 
Array< OneD, Array< OneD,
NekDouble > > 
uv
 
int ni
 
int np
 
int nq
 

Friends

class MemoryManager< OptiFace >
 

Detailed Description

Definition at line 84 of file OptimiseFunctions.h.

Constructor & Destructor Documentation

Nektar::NekMeshUtils::OptiFace::OptiFace ( Array< OneD, Array< OneD, NekDouble > >  a,
map< pair< int, int >, NekDouble w,
set< pair< int, int > >  sp,
CADSurfSharedPtr  su 
)
inline

Definition at line 89 of file OptimiseFunctions.h.

References ni, np, nq, s, spring, uv, and z.

93  {
94  uv = a;
95  z = w;
96  spring = sp;
97  s = su;
98  np = uv.num_elements();
99  nq = 0.5 * (-1 + sqrt(1 + 8 * np));
100  ni = (nq - 3) * (nq - 2) / 2;
101  };
Array< OneD, Array< OneD, NekDouble > > uv
map< pair< int, int >, NekDouble > z
set< pair< int, int > > spring
Nektar::NekMeshUtils::OptiFace::~OptiFace ( )
inline

Definition at line 103 of file OptimiseFunctions.h.

103 {};

Member Function Documentation

DNekMat Nektar::NekMeshUtils::OptiFace::dF ( Array< OneD, NekDouble xitst)
virtual

Reimplemented from Nektar::NekMeshUtils::OptiObj.

Definition at line 417 of file OptimiseFunctions.cpp.

References Nektar::NekMeshUtils::Dot(), Nektar::iterator, and Nektar::NekMeshUtils::Take().

418 {
419  Array<OneD, Array<OneD, NekDouble> > val = uv;
420  for (int i = np - ni; i < np; i++)
421  {
422  val[i][0] = xitst[(i - np + ni) * 2 + 0];
423  val[i][1] = xitst[(i - np + ni) * 2 + 1];
424  }
425 
426  DNekMat ret(ni * 2, 1, 0.0);
427 
428  vector<Array<OneD, NekDouble> > r, dru, drv;
429 
430  for (int i = 0; i < val.num_elements(); i++)
431  {
432  Array<OneD, NekDouble> ri(3), du(3), dv(3);
433  Array<OneD, NekDouble> d1 = s->D1(val[i]);
434  for (int i = 0; i < 3; i++)
435  {
436  ri[i] = d1[i];
437  du[i] = d1[i + 3];
438  dv[i] = d1[i + 6];
439  }
440  r.push_back(ri);
441  dru.push_back(du);
442  drv.push_back(dv);
443  }
444 
445  for (int i = 0; i < ni * 2; i++) // for each of the varibles
446  {
447  int var = floor(i / 2) + np - ni;
448  int tp = i % 2; // 0 is a u 1 is a v
449 
450  set<pair<int, int> >::iterator it;
451  for (it = spring.begin(); it != spring.end();
452  it++) // for each of the springs
453  {
454  Array<OneD, NekDouble> dr1, dr2;
455 
456  if ((*it).first == var)
457  {
458  if (tp == 0)
459  {
460  dr1 = dru[(*it).first];
461  }
462  else
463  {
464  dr1 = drv[(*it).first];
465  }
466  }
467  else
468  {
469  dr1 = Array<OneD, NekDouble>(3, 0.0);
470  }
471 
472  if ((*it).second == var)
473  {
474  if (tp == 0)
475  {
476  dr2 = dru[(*it).second];
477  }
478  else
479  {
480  dr2 = drv[(*it).second];
481  }
482  }
483  else
484  {
485  dr2 = Array<OneD, NekDouble>(3, 0.0);
486  }
487 
488  ret(i, 0) +=
489  2.0 / z[(*it)] *
490  Dot(Take(r[(*it).first], r[(*it).second]), Take(dr1, dr2));
491  }
492  }
493  return ret;
494 }
Array< OneD, NekDouble > Take(Array< OneD, NekDouble > a, Array< OneD, NekDouble > b)
Array< OneD, Array< OneD, NekDouble > > uv
NekDouble Dot(Array< OneD, NekDouble > a, Array< OneD, NekDouble > b)
map< pair< int, int >, NekDouble > z
NekMatrix< NekDouble, StandardMatrixTag > DNekMat
Definition: NekTypeDefs.hpp:52
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
set< pair< int, int > > spring
NekDouble Nektar::NekMeshUtils::OptiFace::F ( Array< OneD, NekDouble xitst)
virtual

Reimplemented from Nektar::NekMeshUtils::OptiObj.

Definition at line 395 of file OptimiseFunctions.cpp.

References Nektar::iterator, and Nektar::NekMeshUtils::Take().

396 {
397  Array<OneD, Array<OneD, NekDouble> > val = uv;
398  for (int i = np - ni; i < np; i++)
399  {
400  val[i][0] = xitst[(i - np + ni) * 2 + 0];
401  val[i][1] = xitst[(i - np + ni) * 2 + 1];
402  }
403 
404  NekDouble ret = 0.0;
405  set<pair<int, int> >::iterator it;
406  for (it = spring.begin(); it != spring.end(); it++)
407  {
408  Array<OneD, NekDouble> dis =
409  Take(s->P(uv[(*it).first]), s->P(uv[(*it).second]));
410  NekDouble norm = dis[0] * dis[0] + dis[1] * dis[1] + dis[2] * dis[2];
411  ret += norm / z[(*it)];
412  }
413 
414  return ret;
415 }
Array< OneD, NekDouble > Take(Array< OneD, NekDouble > a, Array< OneD, NekDouble > b)
Array< OneD, Array< OneD, NekDouble > > uv
map< pair< int, int >, NekDouble > z
double NekDouble
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
set< pair< int, int > > spring
Array< OneD, NekDouble > Nektar::NekMeshUtils::OptiFace::Getli ( )
virtual

Reimplemented from Nektar::NekMeshUtils::OptiObj.

Definition at line 371 of file OptimiseFunctions.cpp.

372 {
373  Array<OneD, NekDouble> li(ni * 2);
374  Array<OneD, NekDouble> bnds = s->GetBounds();
375  for (int i = np - ni; i < np; i++)
376  {
377  li[2 * (i - np + ni) + 0] = bnds[0];
378  li[2 * (i - np + ni) + 1] = bnds[2];
379  }
380  return li;
381 }
Array<OneD, Array<OneD, NekDouble> > Nektar::NekMeshUtils::OptiFace::GetSolution ( )
inline

Definition at line 112 of file OptimiseFunctions.h.

References uv.

113  {
114  return uv;
115  };
Array< OneD, Array< OneD, NekDouble > > uv
Array< OneD, NekDouble > Nektar::NekMeshUtils::OptiFace::Getui ( )
virtual

Reimplemented from Nektar::NekMeshUtils::OptiObj.

Definition at line 383 of file OptimiseFunctions.cpp.

384 {
385  Array<OneD, NekDouble> ui(ni * 2);
386  Array<OneD, NekDouble> bnds = s->GetBounds();
387  for (int i = np - ni; i < np; i++)
388  {
389  ui[2 * (i - np + ni) + 0] = bnds[1];
390  ui[2 * (i - np + ni) + 1] = bnds[3];
391  }
392  return ui;
393 }
Array< OneD, NekDouble > Nektar::NekMeshUtils::OptiFace::Getxi ( )
virtual

Reimplemented from Nektar::NekMeshUtils::OptiObj.

Definition at line 360 of file OptimiseFunctions.cpp.

361 {
362  Array<OneD, NekDouble> ret(ni * 2);
363  for (int i = np - ni; i < np; i++)
364  {
365  ret[2 * (i - np + ni) + 0] = uv[i][0];
366  ret[2 * (i - np + ni) + 1] = uv[i][1];
367  }
368  return ret;
369 }
Array< OneD, Array< OneD, NekDouble > > uv
void Nektar::NekMeshUtils::OptiFace::Update ( Array< OneD, NekDouble xinew)
virtual

Reimplemented from Nektar::NekMeshUtils::OptiObj.

Definition at line 496 of file OptimiseFunctions.cpp.

497 {
498  for (int i = np - ni; i < np; i++)
499  {
500  uv[i][0] = xinew[2 * (i - np + ni) + 0];
501  uv[i][1] = xinew[2 * (i - np + ni) + 1];
502  }
503 }
Array< OneD, Array< OneD, NekDouble > > uv

Friends And Related Function Documentation

friend class MemoryManager< OptiFace >
friend

Definition at line 87 of file OptimiseFunctions.h.

Member Data Documentation

int Nektar::NekMeshUtils::OptiFace::ni
private

Definition at line 122 of file OptimiseFunctions.h.

Referenced by OptiFace().

int Nektar::NekMeshUtils::OptiFace::np
private

Definition at line 122 of file OptimiseFunctions.h.

Referenced by OptiFace().

int Nektar::NekMeshUtils::OptiFace::nq
private

Definition at line 122 of file OptimiseFunctions.h.

Referenced by OptiFace().

CADSurfSharedPtr Nektar::NekMeshUtils::OptiFace::s
private

Definition at line 115 of file OptimiseFunctions.h.

Referenced by OptiFace().

set<pair<int, int> > Nektar::NekMeshUtils::OptiFace::spring
private

Definition at line 120 of file OptimiseFunctions.h.

Referenced by OptiFace().

Array<OneD, Array<OneD, NekDouble> > Nektar::NekMeshUtils::OptiFace::uv
private

Definition at line 121 of file OptimiseFunctions.h.

Referenced by GetSolution(), and OptiFace().

map<pair<int, int>, NekDouble> Nektar::NekMeshUtils::OptiFace::z
private

Definition at line 119 of file OptimiseFunctions.h.

Referenced by OptiFace().