Nektar++
Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
Nektar::GlobalMapping::MappingGeneral Class Reference

#include <MappingGeneral.h>

Inheritance diagram for Nektar::GlobalMapping::MappingGeneral:
[legend]

Static Public Member Functions

static GLOBAL_MAPPING_EXPORT MappingSharedPtr create (const LibUtilities::SessionReaderSharedPtr &pSession, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const TiXmlElement *pMapping)
 Creates an instance of this class. More...
 
- Static Public Member Functions inherited from Nektar::GlobalMapping::Mapping
static GLOBAL_MAPPING_EXPORT MappingSharedPtr Load (const LibUtilities::SessionReaderSharedPtr &pSession, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields)
 Return a pointer to the mapping, creating it on first call. More...
 

Static Public Attributes

static std::string className
 Name of the class. More...
 

Protected Member Functions

void CalculateMetricTerms ()
 
void CalculateChristoffel ()
 
 MappingGeneral (const LibUtilities::SessionReaderSharedPtr &pSession, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields)
 
virtual GLOBAL_MAPPING_EXPORT void v_InitObject (const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const TiXmlElement *pMapping)
 
virtual GLOBAL_MAPPING_EXPORT void v_ContravarToCartesian (const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
 
virtual GLOBAL_MAPPING_EXPORT void v_CovarToCartesian (const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
 
virtual GLOBAL_MAPPING_EXPORT void v_ContravarFromCartesian (const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
 
virtual GLOBAL_MAPPING_EXPORT void v_CovarFromCartesian (const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
 
virtual GLOBAL_MAPPING_EXPORT void v_GetJacobian (Array< OneD, NekDouble > &outarray)
 
virtual GLOBAL_MAPPING_EXPORT void v_GetMetricTensor (Array< OneD, Array< OneD, NekDouble > > &outarray)
 
virtual GLOBAL_MAPPING_EXPORT void v_GetInvMetricTensor (Array< OneD, Array< OneD, NekDouble > > &outarray)
 
virtual GLOBAL_MAPPING_EXPORT void v_ApplyChristoffelContravar (const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
 
virtual GLOBAL_MAPPING_EXPORT void v_ApplyChristoffelCovar (const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
 
virtual GLOBAL_MAPPING_EXPORT void v_UpdateGeomInfo ()
 
- Protected Member Functions inherited from Nektar::GlobalMapping::Mapping
GLOBAL_MAPPING_EXPORT Mapping (const LibUtilities::SessionReaderSharedPtr &pSession, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields)
 Constructor. More...
 
GLOBAL_MAPPING_EXPORT void EvaluateFunction (Array< OneD, MultiRegions::ExpListSharedPtr > pFields, LibUtilities::SessionReaderSharedPtr pSession, std::string pFieldName, Array< OneD, NekDouble > &pArray, const std::string &pFunctionName, NekDouble pTime=NekDouble(0))
 
GLOBAL_MAPPING_EXPORT void EvaluateTimeFunction (LibUtilities::SessionReaderSharedPtr pSession, std::string pFieldName, Array< OneD, NekDouble > &pArray, const std::string &pFunctionName, NekDouble pTime=NekDouble(0))
 
virtual GLOBAL_MAPPING_EXPORT void v_GetCartesianCoordinates (Array< OneD, NekDouble > &out0, Array< OneD, NekDouble > &out1, Array< OneD, NekDouble > &out2)
 
virtual GLOBAL_MAPPING_EXPORT void v_GetCoordVelocity (Array< OneD, Array< OneD, NekDouble > > &outarray)
 
virtual GLOBAL_MAPPING_EXPORT void v_DotGradJacobian (const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, NekDouble > &outarray)
 
virtual GLOBAL_MAPPING_EXPORT void v_LowerIndex (const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
 
virtual GLOBAL_MAPPING_EXPORT void v_RaiseIndex (const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
 
virtual GLOBAL_MAPPING_EXPORT void v_Divergence (const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, NekDouble > &outarray)
 
virtual GLOBAL_MAPPING_EXPORT void v_VelocityLaplacian (const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble alpha)
 
virtual GLOBAL_MAPPING_EXPORT void v_gradgradU (const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
 
virtual GLOBAL_MAPPING_EXPORT void v_CurlCurlField (Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const bool generalized)
 
virtual GLOBAL_MAPPING_EXPORT void v_UpdateMapping (const NekDouble time, const Array< OneD, Array< OneD, NekDouble > > &coords=NullNekDoubleArrayofArray, const Array< OneD, Array< OneD, NekDouble > > &coordsVel=NullNekDoubleArrayofArray)
 
virtual GLOBAL_MAPPING_EXPORT void v_UpdateBCs (const NekDouble time)
 

Protected Attributes

Array< OneD, Array< OneD, NekDouble > > m_metricTensor
 
Array< OneD, Array< OneD, NekDouble > > m_invMetricTensor
 
Array< OneD, Array< OneD, NekDouble > > m_deriv
 
Array< OneD, Array< OneD, NekDouble > > m_invDeriv
 
Array< OneD, Array< OneD, NekDouble > > m_Christoffel
 
Array< OneD, NekDoublem_jac
 
- Protected Attributes inherited from Nektar::GlobalMapping::Mapping
LibUtilities::SessionReaderSharedPtr m_session
 Session reader. More...
 
LibUtilities::FieldIOSharedPtr m_fld
 
Array< OneD, MultiRegions::ExpListSharedPtrm_fields
 
Array< OneD, Array< OneD, NekDouble > > m_coords
 Array with the Cartesian coordinates. More...
 
Array< OneD, Array< OneD, NekDouble > > m_coordsVel
 Array with the velocity of the coordinates. More...
 
Array< OneD, Array< OneD, NekDouble > > m_GeometricInfo
 Array with metric terms of the mapping. More...
 
int m_nConvectiveFields
 Number of velocity components. More...
 
std::string m_funcName
 Name of the function containing the coordinates. More...
 
std::string m_velFuncName
 Name of the function containing the velocity of the coordinates. More...
 
bool m_constantJacobian
 Flag defining if the Jacobian is constant. More...
 
bool m_timeDependent
 Flag defining if the Mapping is time-dependent. More...
 
bool m_fromFunction
 Flag defining if the Mapping is defined by a function. More...
 
Array< OneD, Array< OneD, NekDouble > > m_wk1
 
Array< OneD, Array< OneD, NekDouble > > m_wk2
 
Array< OneD, Array< OneD, NekDouble > > m_tmp
 

Friends

class MemoryManager< MappingGeneral >
 

Additional Inherited Members

- Public Member Functions inherited from Nektar::GlobalMapping::Mapping
virtual GLOBAL_MAPPING_EXPORT ~Mapping ()
 Destructor. More...
 
GLOBAL_MAPPING_EXPORT void InitObject (const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const TiXmlElement *pMapping)
 Initialise the mapping object. More...
 
GLOBAL_MAPPING_EXPORT void ReplaceField (const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields)
 Replace the Expansion List used by the mapping. More...
 
GLOBAL_MAPPING_EXPORT void Output (LibUtilities::FieldMetaDataMap &fieldMetaDataMap, const std::string &outname)
 Output function called when a chk or fld file is written. More...
 
GLOBAL_MAPPING_EXPORT void ContravarToCartesian (const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
 Convert a contravariant vector to the Cartesian system. More...
 
GLOBAL_MAPPING_EXPORT void CovarToCartesian (const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
 Convert a covariant vector to the Cartesian system. More...
 
GLOBAL_MAPPING_EXPORT void ContravarFromCartesian (const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
 Convert a contravariant vector to the transformed system. More...
 
GLOBAL_MAPPING_EXPORT void CovarFromCartesian (const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
 Convert a covariant vector to the transformed system. More...
 
GLOBAL_MAPPING_EXPORT void GetCartesianCoordinates (Array< OneD, NekDouble > &out0, Array< OneD, NekDouble > &out1, Array< OneD, NekDouble > &out2)
 Get the Cartesian coordinates in the field. More...
 
GLOBAL_MAPPING_EXPORT void GetJacobian (Array< OneD, NekDouble > &outarray)
 Get the Jacobian of the transformation. More...
 
GLOBAL_MAPPING_EXPORT void DotGradJacobian (const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, NekDouble > &outarray)
 Calculate the dot product with the gradient of the Jacobian. More...
 
GLOBAL_MAPPING_EXPORT void GetMetricTensor (Array< OneD, Array< OneD, NekDouble > > &outarray)
 Get the metric tensor \(g_{ij}\). More...
 
GLOBAL_MAPPING_EXPORT void GetInvMetricTensor (Array< OneD, Array< OneD, NekDouble > > &outarray)
 Get the inverse of metric tensor \(g^{ij}\). More...
 
GLOBAL_MAPPING_EXPORT void LowerIndex (const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
 Lower index of vector: \(v_{i} = g_{ij}*v^{j}\). More...
 
GLOBAL_MAPPING_EXPORT void RaiseIndex (const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
 Raise index of vector: \(v^{i} = g^{ij}*v_{j}\). More...
 
GLOBAL_MAPPING_EXPORT void ApplyChristoffelContravar (const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
 Apply the Christoffel symbols to a contravariant vector. More...
 
GLOBAL_MAPPING_EXPORT void ApplyChristoffelCovar (const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
 Apply the Christoffel symbols to a covariant vector. More...
 
GLOBAL_MAPPING_EXPORT void GetCoordVelocity (Array< OneD, Array< OneD, NekDouble > > &outarray)
 Obtain the velocity of the coordinates. More...
 
GLOBAL_MAPPING_EXPORT void Divergence (const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, NekDouble > &outarray)
 Calculate the generalised divergence operator. More...
 
GLOBAL_MAPPING_EXPORT void VelocityLaplacian (const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble alpha=0.0)
 Generalised (correction to the) velocity Laplacian operator. More...
 
GLOBAL_MAPPING_EXPORT void gradgradU (const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
 Second order covariant derivatives of a contravariant vector. More...
 
GLOBAL_MAPPING_EXPORT void CurlCurlField (Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const bool generalized)
 CurlCurl calculated on the whole field. More...
 
GLOBAL_MAPPING_EXPORT bool IsTimeDependent ()
 Get flag defining if mapping is time-dependent. More...
 
GLOBAL_MAPPING_EXPORT void SetTimeDependent (const bool value)
 Set flag defining if mapping is time-dependent. More...
 
GLOBAL_MAPPING_EXPORT bool IsFromFunction ()
 Get flag defining if mapping is defined by a function. More...
 
GLOBAL_MAPPING_EXPORT void SetFromFunction (const bool value)
 Set flag defining if mapping is defined by a function. More...
 
GLOBAL_MAPPING_EXPORT bool HasConstantJacobian ()
 Get flag defining if mapping has constant Jacobian. More...
 
GLOBAL_MAPPING_EXPORT bool IsDefined ()
 Get flag determining if the mapping was defined or is trivial. More...
 
GLOBAL_MAPPING_EXPORT void UpdateBCs (const NekDouble time)
 Update the Dirichlet Boundary Conditions when using Mappings. More...
 
GLOBAL_MAPPING_EXPORT void UpdateMapping (const NekDouble time, const Array< OneD, Array< OneD, NekDouble > > &coords=NullNekDoubleArrayofArray, const Array< OneD, Array< OneD, NekDouble > > &coordsVel=NullNekDoubleArrayofArray)
 Update the Mapping with new coordinates. More...
 
GLOBAL_MAPPING_EXPORT void UpdateGeomInfo ()
 Recompute the metric terms of the Mapping. More...
 
- Static Protected Attributes inherited from Nektar::GlobalMapping::Mapping
static MappingSharedPtr m_mappingPtr = MappingSharedPtr()
 
static bool m_init = false
 
static bool m_isDefined = false
 

Detailed Description

This class implements the most general mapping, defined by the transformation

\[ \bar{x} = \bar{x}(x,y,z) \]

\[ \bar{y} = \bar{y}(x,y,z) \]

\[ \bar{z} = \bar{z}(x,y,z) \]

where \((\bar{x},\bar{y},\bar{z})\) are the Cartesian (physical) coordinates and \((x,y,z)\) are the transformed (computational) coordinates.

Definition at line 51 of file MappingGeneral.h.

Constructor & Destructor Documentation

◆ MappingGeneral()

Nektar::GlobalMapping::MappingGeneral::MappingGeneral ( const LibUtilities::SessionReaderSharedPtr pSession,
const Array< OneD, MultiRegions::ExpListSharedPtr > &  pFields 
)
protected

Definition at line 58 of file MappingGeneral.cpp.

61  : Mapping(pSession, pFields)
62 {
63 }
GLOBAL_MAPPING_EXPORT Mapping(const LibUtilities::SessionReaderSharedPtr &pSession, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields)
Constructor.
Definition: Mapping.cpp:58

Member Function Documentation

◆ CalculateChristoffel()

void Nektar::GlobalMapping::MappingGeneral::CalculateChristoffel ( )
protected

Definition at line 401 of file MappingGeneral.cpp.

References Nektar::MultiRegions::DirCartesianMap, m_Christoffel, Nektar::GlobalMapping::Mapping::m_fields, m_invMetricTensor, m_metricTensor, Nektar::GlobalMapping::Mapping::m_nConvectiveFields, CellMLToNektar.cellml_metadata::p, Vmath::Smul(), Vmath::Vadd(), Vmath::Vsub(), and Vmath::Vvtvp().

Referenced by v_UpdateGeomInfo().

402 {
403  int physTot = m_fields[0]->GetTotPoints();
404  int nvel = m_nConvectiveFields;
405 
406  Array<OneD, Array<OneD, NekDouble> > gradG(nvel*nvel*nvel);
407  Array<OneD, Array<OneD, NekDouble> > tmp(nvel*nvel*nvel);
408  m_Christoffel = Array<OneD, Array<OneD, NekDouble> > (nvel*nvel*nvel);
409  // Allocate memory
410  for (int i = 0; i < gradG.num_elements(); i++)
411  {
412  gradG[i] = Array<OneD, NekDouble>(physTot, 0.0);
413  tmp[i] = Array<OneD, NekDouble>(physTot, 0.0);
414  m_Christoffel[i] = Array<OneD, NekDouble>(physTot, 0.0);
415  }
416 
417  // Set wavespace to false and store current value
418  bool waveSpace = m_fields[0]->GetWaveSpace();
419  m_fields[0]->SetWaveSpace(false);
420 
421  //Calculate gradients of g_ij
422  for (int i = 0; i <nvel; i++)
423  {
424  for(int j=0; j<nvel; j++)
425  {
426  for(int k=0; k<nvel; k++)
427  {
428  m_fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[k],
429  m_metricTensor[i*nvel+j],
430  gradG[i*nvel*nvel + j*nvel + k]);
431  }
432  }
433  }
434 
435  // Calculate tmp[p,j,k] = 1/2( gradG[pj,k]+ gradG[pk,j]-gradG[jk,p])
436  for (int p = 0; p <nvel; p++)
437  {
438  for (int j = 0; j < nvel; j++)
439  {
440  for (int k = 0; k < nvel; k++)
441  {
442  Vmath::Vadd(physTot, gradG[p*nvel*nvel + j*nvel + k], 1,
443  gradG[p*nvel*nvel + k*nvel + j], 1,
444  tmp[p*nvel*nvel + j*nvel + k], 1);
445  Vmath::Vsub(physTot, tmp[p*nvel*nvel + j*nvel + k], 1,
446  gradG[j*nvel*nvel + k*nvel + p], 1,
447  tmp[p*nvel*nvel + j*nvel + k], 1);
448  Vmath::Smul(physTot, 0.5, tmp[p*nvel*nvel + j*nvel + k], 1,
449  tmp[p*nvel*nvel + j*nvel + k], 1);
450  }
451  }
452  }
453 
454  // Calculate Christoffel symbols = g^ip tmp[p,j,k]
455  for (int i = 0; i <nvel; i++)
456  {
457  for (int j = 0; j < nvel; j++)
458  {
459  for (int k = 0; k < nvel; k++)
460  {
461  for (int p = 0; p < nvel; p++)
462  {
463  Vmath::Vvtvp(physTot, m_invMetricTensor[i*nvel+p], 1,
464  tmp[p*nvel*nvel + j*nvel + k], 1,
465  m_Christoffel[i*nvel*nvel+j*nvel+k], 1,
466  m_Christoffel[i*nvel*nvel+j*nvel+k], 1);
467  }
468  }
469  }
470  }
471  // Restore wavespace
472  m_fields[0]->SetWaveSpace(waveSpace);
473 
474 }
Array< OneD, Array< OneD, NekDouble > > m_invMetricTensor
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
Definition: Vmath.cpp:445
int m_nConvectiveFields
Number of velocity components.
Definition: Mapping.h:416
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Definition: Mapping.h:408
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
Definition: Vmath.cpp:216
Array< OneD, Array< OneD, NekDouble > > m_Christoffel
void Vsub(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Subtract vector z = x-y.
Definition: Vmath.cpp:346
MultiRegions::Direction const DirCartesianMap[]
Definition: ExpList.h:88
Array< OneD, Array< OneD, NekDouble > > m_metricTensor
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
Definition: Vmath.cpp:302

◆ CalculateMetricTerms()

void Nektar::GlobalMapping::MappingGeneral::CalculateMetricTerms ( )
protected

Definition at line 263 of file MappingGeneral.cpp.

References Nektar::MultiRegions::DirCartesianMap, Nektar::MultiRegions::e3DH1D, Vmath::Fill(), Nektar::GlobalMapping::Mapping::m_coords, m_deriv, Nektar::GlobalMapping::Mapping::m_fields, m_invDeriv, m_invMetricTensor, m_jac, m_metricTensor, Nektar::GlobalMapping::Mapping::m_nConvectiveFields, Vmath::Smul(), Vmath::Vcopy(), Vmath::Vdiv(), Vmath::Vmul(), Vmath::Vsqrt(), Vmath::Vvtvm(), and Vmath::Vvtvp().

Referenced by v_UpdateGeomInfo().

264 {
265  int physTot = m_fields[0]->GetTotPoints();
266  int nvel = m_nConvectiveFields;
267 
268  // Set wavespace to false and store current value
269  bool wavespace = m_fields[0]->GetWaveSpace();
270  m_fields[0]->SetWaveSpace(false);
271 
272  // Allocate memory
273  m_metricTensor = Array<OneD, Array<OneD, NekDouble> >(nvel*nvel);
274  m_invMetricTensor = Array<OneD, Array<OneD, NekDouble> >(nvel*nvel);
275  m_deriv = Array<OneD, Array<OneD, NekDouble> >(nvel*nvel);
276  m_invDeriv = Array<OneD, Array<OneD, NekDouble> >(nvel*nvel);
277  for (int i = 0; i < m_metricTensor.num_elements(); i++)
278  {
279  m_metricTensor[i] = Array<OneD, NekDouble>(physTot, 0.0);
280  m_invMetricTensor[i] = Array<OneD, NekDouble>(physTot, 0.0);
281  m_deriv[i] = Array<OneD, NekDouble>(physTot, 0.0);
282  m_invDeriv[i] = Array<OneD, NekDouble>(physTot, 0.0);
283  }
284  m_jac = Array<OneD, NekDouble>(physTot, 0.0);
285 
286  // First, calculate derivatives of the mapping -> dX^i/dx^j = c^i_j
287  for( int i = 0; i<nvel; i++)
288  {
289  for( int j = 0; j<nvel; j++)
290  {
291  m_fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[j],
292  m_coords[i],
293  m_deriv[i*nvel+j]);
294  }
295  }
296  // In Homogeneous case, m_deriv(2,2) needs to be set to 1
297  // because differentiation in wavespace is not valid for non-periodic field
298  if (m_fields[0]->GetExpType() == MultiRegions::e3DH1D)
299  {
300  Vmath::Fill(physTot, 1.0, m_deriv[2*nvel+2], 1);
301  }
302 
303  // Now calculate the metric tensor --> g_ij = sum_k { c^k_i c^k_j }
304  for( int i = 0; i<nvel; i++)
305  {
306  for( int j = 0; j<nvel; j++)
307  {
308  for( int k = 0; k<nvel; k++)
309  {
310  Vmath::Vvtvp(physTot, m_deriv[k*nvel+i], 1,
311  m_deriv[k*nvel+j], 1,
312  m_metricTensor[i*nvel+j], 1,
313  m_metricTensor[i*nvel+j], 1);
314  }
315  }
316  }
317 
318  // Put the adjoint of g in m_invMetricTensor
319  switch (nvel)
320  {
321  case 1:
322  Vmath::Fill (physTot, 1.0, m_invMetricTensor[0], 1);
323  break;
324  case 2:
325  Vmath::Vcopy(physTot, m_metricTensor[1*nvel+1], 1,
326  m_invMetricTensor[0*nvel+0], 1);
327  Vmath::Smul (physTot, -1.0, m_metricTensor[0*nvel+1], 1,
328  m_invMetricTensor[1*nvel+0], 1);
329  Vmath::Smul (physTot, -1.0, m_metricTensor[1*nvel+0], 1,
330  m_invMetricTensor[0*nvel+1], 1);
331  Vmath::Vcopy(physTot, m_metricTensor[0*nvel+0], 1,
332  m_invMetricTensor[1*nvel+1], 1);
333  break;
334  case 3:
335  {
336  int a, b, c, d, e, i, j;
337 
338  // Compute g^{ij} by computing Cofactors(g_ij)^T
339  for (i = 0; i < nvel; ++i)
340  {
341  for (j = 0; j < nvel; ++j)
342  {
343  a = ((i+1)%nvel) * nvel + ((j+1)%nvel);
344  b = ((i+1)%nvel) * nvel + ((j+2)%nvel);
345  c = ((i+2)%nvel) * nvel + ((j+1)%nvel);
346  d = ((i+2)%nvel) * nvel + ((j+2)%nvel);
347  e = i*nvel + j;
348  // a*d - b*c
349  Vmath::Vmul(physTot, m_metricTensor[b], 1,
350  m_metricTensor[c], 1,
351  m_invMetricTensor[e], 1);
352  Vmath::Vvtvm(physTot, m_metricTensor[a], 1,
353  m_metricTensor[d], 1,
354  m_invMetricTensor[e], 1,
355  m_invMetricTensor[e], 1);
356  }
357  }
358  break;
359  }
360  }
361 
362  // Compute g = det(g_{ij}) (= Jacobian squared) and store
363  // temporarily in m_jac.
364  for (int i = 0; i < nvel; ++i)
365  {
366  Vmath::Vvtvp(physTot, m_metricTensor[i], 1,
367  m_invMetricTensor[i*nvel], 1,
368  m_jac, 1, m_jac, 1);
369  }
370 
371  // Calculate g^ij (the inverse of g_ij) by dividing by jac
372  for (int i = 0; i < nvel*nvel; ++i)
373  {
374  Vmath::Vdiv(physTot, m_invMetricTensor[i], 1, m_jac, 1,
375  m_invMetricTensor[i], 1);
376  }
377 
378  // Compute the Jacobian = sqrt(g)
379  Vmath::Vsqrt(physTot, m_jac, 1, m_jac, 1);
380 
381  // Calculate the derivatives of the inverse transformation
382  // c'^j_i = dx^j/dX^i = sum_k {g^jk c^i_k}
383  for (int i = 0; i < nvel; ++i)
384  {
385  for (int j = 0; j < nvel; ++j)
386  {
387  for (int k = 0; k < nvel; ++k)
388  {
389  Vmath::Vvtvp(physTot, m_deriv[i*nvel+k], 1,
390  m_invMetricTensor[j*nvel+k], 1,
391  m_invDeriv[i*nvel+j], 1,
392  m_invDeriv[i*nvel+j], 1);
393  }
394  }
395  }
396 
397  // Restore value of wavespace
398  m_fields[0]->SetWaveSpace(wavespace);
399 }
Array< OneD, Array< OneD, NekDouble > > m_invMetricTensor
Array< OneD, Array< OneD, NekDouble > > m_coords
Array with the Cartesian coordinates.
Definition: Mapping.h:410
void Vsqrt(int n, const T *x, const int incx, T *y, const int incy)
sqrt y = sqrt(x)
Definition: Vmath.cpp:411
Array< OneD, Array< OneD, NekDouble > > m_invDeriv
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
Definition: Vmath.cpp:45
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
Definition: Vmath.cpp:445
void Vdiv(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x/y.
Definition: Vmath.cpp:244
int m_nConvectiveFields
Number of velocity components.
Definition: Mapping.h:416
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Definition: Mapping.h:408
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
Definition: Vmath.cpp:216
Array< OneD, Array< OneD, NekDouble > > m_deriv
Array< OneD, NekDouble > m_jac
MultiRegions::Direction const DirCartesianMap[]
Definition: ExpList.h:88
void Vvtvm(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvm (vector times vector plus vector): z = w*x - y
Definition: Vmath.cpp:468
Array< OneD, Array< OneD, NekDouble > > m_metricTensor
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1064
void Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x*y.
Definition: Vmath.cpp:186

◆ create()

static GLOBAL_MAPPING_EXPORT MappingSharedPtr Nektar::GlobalMapping::MappingGeneral::create ( const LibUtilities::SessionReaderSharedPtr pSession,
const Array< OneD, MultiRegions::ExpListSharedPtr > &  pFields,
const TiXmlElement *  pMapping 
)
inlinestatic

Creates an instance of this class.

Definition at line 59 of file MappingGeneral.h.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), Nektar::GlobalMapping::MappingSharedPtr, and CellMLToNektar.cellml_metadata::p.

63  {
66  pFields);
67  p->InitObject(pFields, pMapping);
68  return p;
69  }
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
GLOBAL_MAPPING_EXPORT typedef std::shared_ptr< Mapping > MappingSharedPtr
A shared pointer to a Mapping object.
Definition: Mapping.h:50

◆ v_ApplyChristoffelContravar()

void Nektar::GlobalMapping::MappingGeneral::v_ApplyChristoffelContravar ( const Array< OneD, Array< OneD, NekDouble > > &  inarray,
Array< OneD, Array< OneD, NekDouble > > &  outarray 
)
protectedvirtual

Implements Nektar::GlobalMapping::Mapping.

Definition at line 208 of file MappingGeneral.cpp.

References m_Christoffel, Nektar::GlobalMapping::Mapping::m_fields, Nektar::GlobalMapping::Mapping::m_nConvectiveFields, and Vmath::Vvtvp().

211 {
212  int physTot = m_fields[0]->GetTotPoints();
213  int nvel = m_nConvectiveFields;
214 
215  // Calculate {i,jk} u^j
216  for (int i = 0; i <nvel; i++)
217  {
218  for (int k = 0; k < nvel; k++)
219  {
220  outarray[i*nvel+k] = Array<OneD, NekDouble>(physTot,0.0);
221  for (int j = 0; j < nvel; j++)
222  {
223  Vmath::Vvtvp(physTot, inarray[j], 1,
224  m_Christoffel[i*nvel*nvel+j*nvel+k], 1,
225  outarray[i*nvel+k], 1,
226  outarray[i*nvel+k], 1);
227  }
228  }
229  }
230 
231 }
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
Definition: Vmath.cpp:445
int m_nConvectiveFields
Number of velocity components.
Definition: Mapping.h:416
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Definition: Mapping.h:408
Array< OneD, Array< OneD, NekDouble > > m_Christoffel

◆ v_ApplyChristoffelCovar()

void Nektar::GlobalMapping::MappingGeneral::v_ApplyChristoffelCovar ( const Array< OneD, Array< OneD, NekDouble > > &  inarray,
Array< OneD, Array< OneD, NekDouble > > &  outarray 
)
protectedvirtual

Implements Nektar::GlobalMapping::Mapping.

Definition at line 233 of file MappingGeneral.cpp.

References m_Christoffel, Nektar::GlobalMapping::Mapping::m_fields, Nektar::GlobalMapping::Mapping::m_nConvectiveFields, and Vmath::Vvtvp().

236 {
237  int physTot = m_fields[0]->GetTotPoints();
238  int nvel = m_nConvectiveFields;
239 
240  // Calculate {i,jk} u_i
241  for (int j = 0; j < nvel; j++)
242  {
243  for (int k = 0; k < nvel; k++)
244  {
245  outarray[j*nvel+k] = Array<OneD, NekDouble>(physTot,0.0);
246  for (int i = 0; i <nvel; i++)
247  {
248  Vmath::Vvtvp(physTot, inarray[i], 1,
249  m_Christoffel[i*nvel*nvel+j*nvel+k], 1,
250  outarray[j*nvel+k], 1,
251  outarray[j*nvel+k], 1);
252  }
253  }
254  }
255 }
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
Definition: Vmath.cpp:445
int m_nConvectiveFields
Number of velocity components.
Definition: Mapping.h:416
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Definition: Mapping.h:408
Array< OneD, Array< OneD, NekDouble > > m_Christoffel

◆ v_ContravarFromCartesian()

void Nektar::GlobalMapping::MappingGeneral::v_ContravarFromCartesian ( const Array< OneD, Array< OneD, NekDouble > > &  inarray,
Array< OneD, Array< OneD, NekDouble > > &  outarray 
)
protectedvirtual

Implements Nektar::GlobalMapping::Mapping.

Definition at line 123 of file MappingGeneral.cpp.

References Nektar::GlobalMapping::Mapping::m_fields, m_invDeriv, Nektar::GlobalMapping::Mapping::m_nConvectiveFields, and Vmath::Vvtvp().

126 {
127  int physTot = m_fields[0]->GetTotPoints();
128  int nvel = m_nConvectiveFields;
129 
130  for (int i=0; i<nvel; i++)
131  {
132  outarray[i] = Array<OneD, NekDouble> (physTot, 0.0);
133  for (int j=0; j<nvel; j++)
134  {
135  Vmath::Vvtvp(physTot, inarray[j], 1,
136  m_invDeriv[j*nvel+i], 1,
137  outarray[i], 1,
138  outarray[i], 1);
139  }
140 
141  }
142 }
Array< OneD, Array< OneD, NekDouble > > m_invDeriv
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
Definition: Vmath.cpp:445
int m_nConvectiveFields
Number of velocity components.
Definition: Mapping.h:416
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Definition: Mapping.h:408

◆ v_ContravarToCartesian()

void Nektar::GlobalMapping::MappingGeneral::v_ContravarToCartesian ( const Array< OneD, Array< OneD, NekDouble > > &  inarray,
Array< OneD, Array< OneD, NekDouble > > &  outarray 
)
protectedvirtual

Implements Nektar::GlobalMapping::Mapping.

Definition at line 81 of file MappingGeneral.cpp.

References m_deriv, Nektar::GlobalMapping::Mapping::m_fields, Nektar::GlobalMapping::Mapping::m_nConvectiveFields, and Vmath::Vvtvp().

84 {
85  int physTot = m_fields[0]->GetTotPoints();
86  int nvel = m_nConvectiveFields;
87 
88  for (int i=0; i<nvel; i++)
89  {
90  outarray[i] = Array<OneD, NekDouble> (physTot, 0.0);
91  for (int j=0; j<nvel; j++)
92  {
93  Vmath::Vvtvp(physTot, inarray[j], 1,
94  m_deriv[i*nvel+j], 1,
95  outarray[i], 1,
96  outarray[i], 1);
97  }
98 
99  }
100 }
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
Definition: Vmath.cpp:445
int m_nConvectiveFields
Number of velocity components.
Definition: Mapping.h:416
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Definition: Mapping.h:408
Array< OneD, Array< OneD, NekDouble > > m_deriv

◆ v_CovarFromCartesian()

void Nektar::GlobalMapping::MappingGeneral::v_CovarFromCartesian ( const Array< OneD, Array< OneD, NekDouble > > &  inarray,
Array< OneD, Array< OneD, NekDouble > > &  outarray 
)
protectedvirtual

Implements Nektar::GlobalMapping::Mapping.

Definition at line 144 of file MappingGeneral.cpp.

References m_deriv, Nektar::GlobalMapping::Mapping::m_fields, Nektar::GlobalMapping::Mapping::m_nConvectiveFields, and Vmath::Vvtvp().

147 {
148  int physTot = m_fields[0]->GetTotPoints();
149  int nvel = m_nConvectiveFields;
150 
151  for (int i=0; i<nvel; i++)
152  {
153  outarray[i] = Array<OneD, NekDouble> (physTot, 0.0);
154  for (int j=0; j<nvel; j++)
155  {
156  Vmath::Vvtvp(physTot, inarray[j], 1,
157  m_deriv[j*nvel+i], 1,
158  outarray[i], 1,
159  outarray[i], 1);
160  }
161 
162  }
163 }
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
Definition: Vmath.cpp:445
int m_nConvectiveFields
Number of velocity components.
Definition: Mapping.h:416
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Definition: Mapping.h:408
Array< OneD, Array< OneD, NekDouble > > m_deriv

◆ v_CovarToCartesian()

void Nektar::GlobalMapping::MappingGeneral::v_CovarToCartesian ( const Array< OneD, Array< OneD, NekDouble > > &  inarray,
Array< OneD, Array< OneD, NekDouble > > &  outarray 
)
protectedvirtual

Implements Nektar::GlobalMapping::Mapping.

Definition at line 102 of file MappingGeneral.cpp.

References Nektar::GlobalMapping::Mapping::m_fields, m_invDeriv, Nektar::GlobalMapping::Mapping::m_nConvectiveFields, and Vmath::Vvtvp().

105 {
106  int physTot = m_fields[0]->GetTotPoints();
107  int nvel = m_nConvectiveFields;
108 
109  for (int i=0; i<nvel; i++)
110  {
111  outarray[i] = Array<OneD, NekDouble> (physTot, 0.0);
112  for (int j=0; j<nvel; j++)
113  {
114  Vmath::Vvtvp(physTot, inarray[j], 1,
115  m_invDeriv[i*nvel+j], 1,
116  outarray[i], 1,
117  outarray[i], 1);
118  }
119 
120  }
121 }
Array< OneD, Array< OneD, NekDouble > > m_invDeriv
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
Definition: Vmath.cpp:445
int m_nConvectiveFields
Number of velocity components.
Definition: Mapping.h:416
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Definition: Mapping.h:408

◆ v_GetInvMetricTensor()

void Nektar::GlobalMapping::MappingGeneral::v_GetInvMetricTensor ( Array< OneD, Array< OneD, NekDouble > > &  outarray)
protectedvirtual

Implements Nektar::GlobalMapping::Mapping.

Definition at line 190 of file MappingGeneral.cpp.

References Nektar::GlobalMapping::Mapping::m_fields, m_invMetricTensor, Nektar::GlobalMapping::Mapping::m_nConvectiveFields, and Vmath::Vcopy().

192 {
193  int physTot = m_fields[0]->GetTotPoints();
194  int nvel = m_nConvectiveFields;
195 
196  for (int i=0; i<nvel; i++)
197  {
198  for (int j=0; j<nvel; j++)
199  {
200  outarray[i*nvel+j] = Array<OneD, NekDouble> (physTot, 0.0);
201  Vmath::Vcopy(physTot, m_invMetricTensor[i*nvel+j], 1,
202  outarray[i*nvel+j], 1);
203  }
204 
205  }
206 }
Array< OneD, Array< OneD, NekDouble > > m_invMetricTensor
int m_nConvectiveFields
Number of velocity components.
Definition: Mapping.h:416
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Definition: Mapping.h:408
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1064

◆ v_GetJacobian()

void Nektar::GlobalMapping::MappingGeneral::v_GetJacobian ( Array< OneD, NekDouble > &  outarray)
protectedvirtual

Implements Nektar::GlobalMapping::Mapping.

Definition at line 165 of file MappingGeneral.cpp.

References Nektar::GlobalMapping::Mapping::m_fields, m_jac, and Vmath::Vcopy().

167 {
168  int physTot = m_fields[0]->GetTotPoints();
169  Vmath::Vcopy(physTot, m_jac, 1, outarray, 1);
170 }
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Definition: Mapping.h:408
Array< OneD, NekDouble > m_jac
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1064

◆ v_GetMetricTensor()

void Nektar::GlobalMapping::MappingGeneral::v_GetMetricTensor ( Array< OneD, Array< OneD, NekDouble > > &  outarray)
protectedvirtual

Implements Nektar::GlobalMapping::Mapping.

Definition at line 172 of file MappingGeneral.cpp.

References Nektar::GlobalMapping::Mapping::m_fields, m_metricTensor, Nektar::GlobalMapping::Mapping::m_nConvectiveFields, and Vmath::Vcopy().

174 {
175  int physTot = m_fields[0]->GetTotPoints();
176  int nvel = m_nConvectiveFields;
177 
178  for (int i=0; i<nvel; i++)
179  {
180  for (int j=0; j<nvel; j++)
181  {
182  outarray[i*nvel+j] = Array<OneD, NekDouble> (physTot, 0.0);
183  Vmath::Vcopy(physTot, m_metricTensor[i*nvel+j], 1,
184  outarray[i*nvel+j], 1);
185  }
186 
187  }
188 }
int m_nConvectiveFields
Number of velocity components.
Definition: Mapping.h:416
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Definition: Mapping.h:408
Array< OneD, Array< OneD, NekDouble > > m_metricTensor
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1064

◆ v_InitObject()

void Nektar::GlobalMapping::MappingGeneral::v_InitObject ( const Array< OneD, MultiRegions::ExpListSharedPtr > &  pFields,
const TiXmlElement *  pMapping 
)
protectedvirtual

This function initialises the Mapping object. It computes the coordinates and velocity coordinates, initialises the workspace variables, and calls UpdateGeomInfo, which will perform the calculations specific for each type of Mapping.

Parameters
pFieldsExpList array used in the mapping
pMappingxml element describing the mapping

Reimplemented from Nektar::GlobalMapping::Mapping.

Definition at line 69 of file MappingGeneral.cpp.

References ASSERTL0, Nektar::GlobalMapping::Mapping::m_constantJacobian, Nektar::GlobalMapping::Mapping::m_nConvectiveFields, and Nektar::GlobalMapping::Mapping::v_InitObject().

72 {
73  Mapping::v_InitObject(pFields, pMapping);
74 
75  m_constantJacobian = false;
76 
78  "General Mapping needs at least 2 velocity components.");
79 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
int m_nConvectiveFields
Number of velocity components.
Definition: Mapping.h:416
virtual GLOBAL_MAPPING_EXPORT void v_InitObject(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const TiXmlElement *pMapping)
Definition: Mapping.cpp:100
bool m_constantJacobian
Flag defining if the Jacobian is constant.
Definition: Mapping.h:426

◆ v_UpdateGeomInfo()

void Nektar::GlobalMapping::MappingGeneral::v_UpdateGeomInfo ( )
protectedvirtual

Friends And Related Function Documentation

◆ MemoryManager< MappingGeneral >

friend class MemoryManager< MappingGeneral >
friend

Definition at line 55 of file MappingGeneral.h.

Member Data Documentation

◆ className

std::string Nektar::GlobalMapping::MappingGeneral::className
static
Initial value:
=
MappingGeneral::create, "X = X(x,y,z), Y = Y(x,y,z), Z=Z(x,y,z)")

Name of the class.

Definition at line 72 of file MappingGeneral.h.

◆ m_Christoffel

Array<OneD, Array<OneD, NekDouble> > Nektar::GlobalMapping::MappingGeneral::m_Christoffel
protected

◆ m_deriv

Array<OneD, Array<OneD, NekDouble> > Nektar::GlobalMapping::MappingGeneral::m_deriv
protected

◆ m_invDeriv

Array<OneD, Array<OneD, NekDouble> > Nektar::GlobalMapping::MappingGeneral::m_invDeriv
protected

◆ m_invMetricTensor

Array<OneD, Array<OneD, NekDouble> > Nektar::GlobalMapping::MappingGeneral::m_invMetricTensor
protected

◆ m_jac

Array<OneD, NekDouble> Nektar::GlobalMapping::MappingGeneral::m_jac
protected

Definition at line 86 of file MappingGeneral.h.

Referenced by CalculateMetricTerms(), and v_GetJacobian().

◆ m_metricTensor

Array<OneD, Array<OneD, NekDouble> > Nektar::GlobalMapping::MappingGeneral::m_metricTensor
protected

Definition at line 81 of file MappingGeneral.h.

Referenced by CalculateChristoffel(), CalculateMetricTerms(), and v_GetMetricTensor().