Nektar++
Mapping.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: Mapping.cpp
4 //
5 // For more information, please see: http://www.nektar.info
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // Permission is hereby granted, free of charge, to any person obtaining a
14 // copy of this software and associated documentation files (the "Software"),
15 // to deal in the Software without restriction, including without limitation
16 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 // and/or sell copies of the Software, and to permit persons to whom the
18 // Software is furnished to do so, subject to the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be included
21 // in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 // DEALINGS IN THE SOFTWARE.
30 //
31 // Description: Abstract base class for mappings.
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #include <boost/core/ignore_unused.hpp>
36 
37 #include <GlobalMapping/Mapping.h>
38 
39 #include <boost/algorithm/string/predicate.hpp>
40 
41 using namespace std;
42 
43 namespace Nektar
44 {
45 namespace GlobalMapping
46 {
47 
48 MappingSharedPtr Mapping::m_mappingPtr = MappingSharedPtr();
49 bool Mapping::m_init = false;
50 bool Mapping::m_isDefined = false;
51 
53 {
54  static MappingFactory instance;
55  return instance;
56 }
57 
58 Mapping::Mapping(const LibUtilities::SessionReaderSharedPtr& pSession,
60  : m_session(pSession), m_fields(pFields)
61 {
62  switch (m_fields[0]->GetExpType())
63  {
64  case MultiRegions::e1D:
65  {
67  }
68  break;
69 
70  case MultiRegions::e2D:
71  {
73  }
74  break;
75 
76  case MultiRegions::e3D:
79  {
81  }
82  break;
83 
84  default:
85  ASSERTL0(0,"Dimension not supported");
86  break;
87  }
88 
90 }
91 
92 /**
93  * This function initialises the Mapping object. It computes the coordinates
94  * and velocity coordinates, initialises the workspace variables, and calls
95  * UpdateGeomInfo, which will perform the calculations specific for each type
96  * of Mapping.
97  * @param pFields ExpList array used in the mapping
98  * @param pMapping xml element describing the mapping
99  */
102  const TiXmlElement *pMapping)
103 {
104  boost::ignore_unused(pFields);
105 
106  int phystot = m_fields[0]->GetTotPoints();
107  m_fromFunction = true;
108  // Initialise variables
112  for (int i = 0; i < 3; i++)
113  {
114  m_coords[i] = Array<OneD, NekDouble> (phystot);
115  m_coordsVel[i] = Array<OneD, NekDouble> (phystot);
116  coords[i] = Array<OneD, NekDouble> (phystot);
117  }
118 
119  // Check if mapping is defined as time-dependent
120  const TiXmlElement* timeDep = pMapping->
121  FirstChildElement("TIMEDEPENDENT");
122  if (timeDep)
123  {
124  string sTimeDep = timeDep->GetText();
125  m_timeDependent = ( boost::iequals(sTimeDep,"true")) ||
126  ( boost::iequals(sTimeDep,"yes"));
127  }
128  else
129  {
130  m_timeDependent = false;
131  }
132 
133  // Load coordinates
134  string fieldNames[3] = {"x", "y", "z"};
135  const TiXmlElement* funcNameElmt = pMapping->FirstChildElement("COORDS");
136  if (funcNameElmt)
137  {
138  m_funcName = funcNameElmt->GetText();
139  ASSERTL0(m_session->DefinesFunction(m_funcName),
140  "Function '" + m_funcName + "' not defined.");
141 
142  // Get coordinates in the domain
143  m_fields[0]->GetCoords(coords[0], coords[1], coords[2]);
144 
145  std::string s_FieldStr;
146  // Check if function from session file defines each component
147  // and evaluate them, otherwise use trivial transformation
148  for(int i = 0; i < 3; i++)
149  {
150  s_FieldStr = fieldNames[i];
151  if ( m_session->DefinesFunction(m_funcName, s_FieldStr))
152  {
153  EvaluateFunction(m_fields, m_session, s_FieldStr, m_coords[i],
154  m_funcName);
155  if ( i==2 && m_fields[0]->GetExpType() == MultiRegions::e3DH1D)
156  {
157  ASSERTL0 (false,
158  "3DH1D does not support mapping in the z-direction.");
159  }
160  }
161  else
162  {
163  // This coordinate is not defined, so use (x^i)' = x^i
164  Vmath::Vcopy(phystot, coords[i], 1, m_coords[i], 1);
165  }
166  }
167  }
168  else
169  {
170  m_fields[0]->GetCoords(coords[0], coords[1], coords[2]);
171  for(int i = 0; i < 3; i++)
172  {
173  // Use (x^i)' = x^i as default. This can be useful if we
174  // have a time-dependent mapping, and then only the
175  // initial mapping will be trivial
176  Vmath::Vcopy(phystot, coords[i], 1, m_coords[i], 1);
177  }
178  }
179 
180  // Load coordinate velocity if they are defined,
181  // otherwise use zero to make it general
182  string velFieldNames[3] = {"vx", "vy", "vz"};
183  const TiXmlElement* velFuncNameElmt = pMapping->FirstChildElement("VEL");
184  if (velFuncNameElmt)
185  {
186  m_velFuncName = velFuncNameElmt->GetText();
187  ASSERTL0(m_session->DefinesFunction(m_velFuncName),
188  "Function '" + m_velFuncName + "' not defined.");
189 
190  std::string s_FieldStr;
191  // Check if function from session file defines each component
192  // and evaluate them, otherwise use 0
193  for(int i = 0; i < 3; i++)
194  {
195  s_FieldStr = velFieldNames[i];
196  if ( m_session->DefinesFunction(m_velFuncName, s_FieldStr))
197  {
198  EvaluateFunction(m_fields, m_session, s_FieldStr,
200  if ( i==2 && m_fields[0]->GetExpType() == MultiRegions::e3DH1D)
201  {
202  ASSERTL0 (false,
203  "3DH1D does not support mapping in the z-direction.");
204  }
205  }
206  else
207  {
208  // This coordinate velocity is not defined, so use 0
209  Vmath::Zero(phystot, m_coordsVel[i], 1);
210  }
211  }
212  }
213  else
214  {
215  for(int i = 0; i < 3; i++)
216  {
217  Vmath::Zero(phystot, m_coordsVel[i], 1);
218  }
219  }
220 
221  // Initialise workspace variables
222  int nvel = m_nConvectiveFields;
226  for (int i=0; i< nvel; i++)
227  {
228  m_tmp[i] = Array<OneD, NekDouble>(phystot,0.0);
229  for (int j=0; j< nvel; j++)
230  {
231  m_wk1[i*nvel+j] = Array<OneD, NekDouble>(phystot,0.0);
232  m_wk2[i*nvel+j] = Array<OneD, NekDouble>(phystot,0.0);
233  }
234  }
235 
236  // Calculate information required by the particular mapping
237  UpdateGeomInfo();
238 }
239 
240 /**
241  * This function replaces the expansion list contained in m_fields, and then
242  * proceeds reinitialising the Mapping with this new field.
243  * @param pFields New field to be used by the Mapping
244  */
247 {
248  m_fields = pFields;
249 
250  TiXmlElement* vMapping = NULL;
251 
252  if (m_session->DefinesElement("Nektar/Mapping"))
253  {
254  vMapping = m_session->GetElement("Nektar/Mapping");
255  }
256  InitObject(pFields, vMapping);
257 }
258 
259 /**
260  * This function is responsible for loading the Mapping, guaranteeing that a
261  * single instance of this class exists. When it is first called, it creates a
262  * Mapping and returns a pointer to it. On subsequent calls, it just returns
263  * the pointer.
264  * @param pSession Session reader object
265  * @param pFields Fields which will be used by the Mapping
266  * @return Pointer to the Mapping
267  */
269  const LibUtilities::SessionReaderSharedPtr& pSession,
271 {
272  if (!m_init)
273  {
274  TiXmlElement* vMapping = NULL;
275  string vType;
276  if (pSession->DefinesElement("Nektar/Mapping"))
277  {
278  vMapping = pSession->GetElement("Nektar/Mapping");
279  vType = vMapping->Attribute("TYPE");
280  m_isDefined = true;
281  }
282  else
283  {
284  vType = "Translation";
285  }
286 
288  vType, pSession, pFields,
289  vMapping);
290 
291  m_init = true;
292  }
293 
294  return m_mappingPtr;
295 }
296 
297 /**
298  * This function should be called before writing a fld or chk file. It updates
299  * the metadata with information from the Mapping. Also, if the mapping is not
300  * defined by a function, it writes a .map file containing the coordinates and
301  * velocity of the coordinates.
302  * @param fieldMetaDataMap Metadata of the output file
303  * @param outname Name of the output file
304  */
306  LibUtilities::FieldMetaDataMap &fieldMetaDataMap,
307  const std::string &outname)
308 {
309  // Only do anything if mapping exists
310  if (m_isDefined)
311  {
312  fieldMetaDataMap["MappingCartesianVel"] = std::string("False");
313  if (m_fromFunction)
314  {
315  // Add metadata
316  fieldMetaDataMap["MappingType"] = std::string("Expression");
317  fieldMetaDataMap["MappingExpression"] = m_funcName;
318  if (m_timeDependent)
319  {
320  fieldMetaDataMap["MappingVelExpression"] = m_velFuncName;
321  }
322  }
323  else
324  {
325  int expdim = m_fields[0]->GetGraph()->GetMeshDimension();
326  string fieldNames[3] = {"x", "y", "z"};
327  string velFieldNames[3] = {"vx", "vy", "vz"};
328 
329  std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
330  = m_fields[0]->GetFieldDefinitions();
331  std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
332 
333  int ncoeffs = m_fields[0]->GetNcoeffs();
334  Array<OneD, NekDouble> fieldcoeffs(ncoeffs);
335 
336  bool wavespace = m_fields[0]->GetWaveSpace();
337  m_fields[0]->SetWaveSpace(false);
338  // copy coordinates Data into FieldData and set variable
339  for(int j = 0; j < expdim; ++j)
340  {
341  m_fields[0]->FwdTrans_IterPerExp(m_coords[j], fieldcoeffs);
342 
343  for(int i = 0; i < FieldDef.size(); ++i)
344  {
345  // Could do a search here to find correct variable
346  FieldDef[i]->m_fields.push_back(fieldNames[j]);
347  m_fields[0]->AppendFieldData(FieldDef[i], FieldData[i],
348  fieldcoeffs);
349  }
350  }
351  if (m_timeDependent)
352  {
353  //copy coordinates velocity Data into FieldData and set variable
354  for(int j = 0; j < expdim; ++j)
355  {
356  m_fields[0]->FwdTrans_IterPerExp(m_coordsVel[j],
357  fieldcoeffs);
358 
359  for(int i = 0; i < FieldDef.size(); ++i)
360  {
361  // Could do a search here to find correct variable
362  FieldDef[i]->m_fields.push_back(velFieldNames[j]);
363  m_fields[0]->AppendFieldData(FieldDef[i],
364  FieldData[i],
365  fieldcoeffs);
366  }
367  }
368  }
369 
370  std::string outfile = outname;
371  outfile.erase(outfile.end()-4, outfile.end());
372  outfile += ".map";
373 
374  m_fld->Write(outfile,FieldDef,FieldData,fieldMetaDataMap);
375 
376  // Write metadata to orginal output
377  fieldMetaDataMap["MappingType"] = std::string("File");
378  fieldMetaDataMap["FileName"] = outfile;
379 
380  m_fields[0]->SetWaveSpace(wavespace);
381  }
382  }
383 }
384 
387  std::string pFieldName,
388  Array<OneD, NekDouble>& pArray,
389  const std::string& pFunctionName,
390  NekDouble pTime)
391 {
392  ASSERTL0(pSession->DefinesFunction(pFunctionName),
393  "Function '" + pFunctionName + "' does not exist.");
394 
396  pSession->GetFunction(pFunctionName, pFieldName);
397 
398  Array<OneD, NekDouble> x0(1,0.0);
399  Array<OneD, NekDouble> x1(1,0.0);
400  Array<OneD, NekDouble> x2(1,0.0);
401 
402  ffunc->Evaluate(x0, x1, x2, pTime, pArray);
403 }
404 
405 
409  std::string pFieldName,
410  Array<OneD, NekDouble>& pArray,
411  const std::string& pFunctionName,
412  NekDouble pTime)
413 {
414  ASSERTL0(pSession->DefinesFunction(pFunctionName),
415  "Function '" + pFunctionName + "' does not exist.");
416 
417  unsigned int nq = pFields[0]->GetNpoints();
418  if (pArray.size() != nq)
419  {
420  pArray = Array<OneD, NekDouble> (nq);
421  }
422 
424  vType = pSession->GetFunctionType(pFunctionName, pFieldName);
426  {
427  Array<OneD, NekDouble> x0(nq);
428  Array<OneD, NekDouble> x1(nq);
429  Array<OneD, NekDouble> x2(nq);
430 
431  pFields[0]->GetCoords(x0, x1, x2);
433  pSession->GetFunction(pFunctionName, pFieldName);
434 
435  ffunc->Evaluate(x0, x1, x2, pTime, pArray);
436  }
437  else if (vType == LibUtilities::eFunctionTypeFile)
438  {
439  std::string filename = pSession->GetFunctionFilename(
440  pFunctionName,
441  pFieldName);
442 
443  std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef;
444  std::vector<std::vector<NekDouble> > FieldData;
445  Array<OneD, NekDouble> vCoeffs(pFields[0]->GetNcoeffs());
446  Vmath::Zero(vCoeffs.size(), vCoeffs, 1);
447 
449  LibUtilities::FieldIO::CreateForFile(pSession, filename);
450  fld->Import(filename, FieldDef, FieldData);
451 
452  int idx = -1;
453  for (int i = 0; i < FieldDef.size(); ++i)
454  {
455  for (int j = 0; j < FieldDef[i]->m_fields.size(); ++j)
456  {
457  if (FieldDef[i]->m_fields[j] == pFieldName)
458  {
459  idx = j;
460  }
461  }
462 
463  if (idx >= 0)
464  {
465  pFields[0]->ExtractDataToCoeffs(
466  FieldDef[i],
467  FieldData[i],
468  FieldDef[i]->m_fields[idx],
469  vCoeffs);
470  }
471  else
472  {
473  cout << "Field " + pFieldName + " not found." << endl;
474  }
475  }
476  pFields[0]->BwdTrans_IterPerExp(vCoeffs, pArray);
477  }
478 }
479 
480 /**
481  * This function converts a contravariant vector in transformed space
482  * \f$v^{j}\f$ to the corresponding \f$\bar{v}^{i}\f$ in Cartesian (physical)
483  * space using the relation
484  * \f[\bar{v}^{i} = \frac{\partial \bar{x}^i}{\partial x^j}v^{j}\f]
485  *
486  * @param inarray Components of the vector in transformed space (\f$v^{j}\f$)
487  * @param outarray Components of the vector in Cartesian space (\f$\bar{v}^{i}\f$)
488  */
490  const Array<OneD, Array<OneD, NekDouble> > &inarray,
491  Array<OneD, Array<OneD, NekDouble> > &outarray)
492 {
493  if(inarray == outarray)
494  {
495  int physTot = m_fields[0]->GetTotPoints();
496  int nvel = m_nConvectiveFields;
497 
498  for (int i=0; i< nvel; i++)
499  {
500  Vmath::Vcopy(physTot, inarray[i], 1, m_tmp[i], 1);
501  }
502  v_ContravarToCartesian( m_tmp, outarray);
503  }
504  else
505  {
506  v_ContravarToCartesian( inarray, outarray);
507  }
508 }
509 
510 /**
511  * This function converts a covariant vector in transformed space
512  * \f$v_{j}\f$ to the corresponding \f$\bar{v}_{i}\f$ in Cartesian (physical)
513  * space using the relation
514  * \f[\bar{v}_{i} = \frac{\partial x^j}{\partial \bar{x}^i}v_{j}\f]
515  *
516  * @param inarray Components of the vector in transformed space (\f$v_{j}\f$)
517  * @param outarray Components of the vector in Cartesian space (\f$\bar{v}_{i}\f$)
518  */
520  const Array<OneD, Array<OneD, NekDouble> > &inarray,
521  Array<OneD, Array<OneD, NekDouble> > &outarray)
522 {
523  if(inarray == outarray)
524  {
525  int physTot = m_fields[0]->GetTotPoints();
526  int nvel = m_nConvectiveFields;
527 
528  for (int i=0; i< nvel; i++)
529  {
530  Vmath::Vcopy(physTot, inarray[i], 1, m_tmp[i], 1);
531  }
532  v_CovarToCartesian( m_tmp, outarray);
533  }
534  else
535  {
536  v_CovarToCartesian( inarray, outarray);
537  }
538 }
539 
540 /**
541  * This function converts a contravariant vector in Cartesian space
542  * \f$\bar{v}^{i}\f$ to the corresponding \f$v^{j}\f$ in transformed
543  * space using the relation
544  * \f[v^{j} = \frac{\partial x^j}{\partial \bar{x}^i}\bar{v}^{i}\f]
545  *
546  * @param inarray Components of the vector in Cartesian space (\f$\bar{v}^{i}\f$)
547  * @param outarray Components of the vector in transformed space (\f$v^{j}\f$)
548  */
550  const Array<OneD, Array<OneD, NekDouble> > &inarray,
551  Array<OneD, Array<OneD, NekDouble> > &outarray)
552 {
553  if(inarray == outarray)
554  {
555  int physTot = m_fields[0]->GetTotPoints();
556  int nvel = m_nConvectiveFields;
557 
558  for (int i=0; i< nvel; i++)
559  {
560  Vmath::Vcopy(physTot, inarray[i], 1, m_tmp[i], 1);
561  }
562  v_ContravarFromCartesian( m_tmp, outarray);
563  }
564  else
565  {
566  v_ContravarFromCartesian( inarray, outarray);
567  }
568 }
569 
570 /**
571  * This function converts a covariant vector in Cartesian space
572  * \f$\bar{v}_{i}\f$ to the corresponding \f$v_{j}\f$ in transformed
573  * space using the relation
574  * \f[\bar{v}_{j} = \frac{\partial \bar{x}^i}{\partial x^j}v_{i}\f]
575  *
576  * @param inarray Components of the vector in Cartesian space (\f$\bar{v}_{i}\f$)
577  * @param outarray Components of the vector in transformed space (\f$v_{j}\f$)
578  */
580  const Array<OneD, Array<OneD, NekDouble> > &inarray,
581  Array<OneD, Array<OneD, NekDouble> > &outarray)
582 {
583  if(inarray == outarray)
584  {
585  int physTot = m_fields[0]->GetTotPoints();
586  int nvel = m_nConvectiveFields;
587 
588  for (int i=0; i< nvel; i++)
589  {
590  Vmath::Vcopy(physTot, inarray[i], 1, m_tmp[i], 1);
591  }
592  v_CovarFromCartesian( m_tmp, outarray);
593  }
594  else
595  {
596  v_CovarFromCartesian( inarray, outarray);
597  }
598 }
599 
600 /**
601  * This function lowers the index of the contravariant vector \f$v^{i}\f$,
602  * transforming it into its associated covariant vector \f$v_{j}\f$
603  * according to the relation
604  * \f[v_{j} = g_{ij}v^{i}\f]
605  * where \f$g_{ij}\f$ is the metric tensor.
606  *
607  * @param inarray Components of the contravariant vector \f$v^{i}\f$
608  * @param outarray Components of the covariant vector \f$v_{j}\f$
609  */
611  const Array<OneD, Array<OneD, NekDouble> > &inarray,
612  Array<OneD, Array<OneD, NekDouble> > &outarray)
613 {
614  if(inarray == outarray)
615  {
616  int physTot = m_fields[0]->GetTotPoints();
617  int nvel = m_nConvectiveFields;
618 
619  for (int i=0; i< nvel; i++)
620  {
621  Vmath::Vcopy(physTot, inarray[i], 1, m_tmp[i], 1);
622  }
623  v_LowerIndex( m_tmp, outarray);
624  }
625  else
626  {
627  v_LowerIndex( inarray, outarray);
628  }
629 }
630 
631 /**
632  * This function raises the index of the covariant vector \f$v_{j}\f$,
633  * transforming it into its associated contravariant vector \f$v^{i}\f$
634  * according to the relation
635  * \f[v^{i} = g^{ij}v_{j}\f]
636  * where \f$g^{ij}\f$ is the inverse of the metric tensor.
637  *
638  * @param inarray Components of the contravariant vector \f$v^{i}\f$
639  * @param outarray Components of the covariant vector \f$v_{j}\f$
640  */
642  const Array<OneD, Array<OneD, NekDouble> > &inarray,
643  Array<OneD, Array<OneD, NekDouble> > &outarray)
644 {
645  if(inarray == outarray)
646  {
647  int physTot = m_fields[0]->GetTotPoints();
648  int nvel = m_nConvectiveFields;
649 
650  for (int i=0; i< nvel; i++)
651  {
652  Vmath::Vcopy(physTot, inarray[i], 1, m_tmp[i], 1);
653  }
654  v_RaiseIndex( m_tmp, outarray);
655  }
656  else
657  {
658  v_RaiseIndex( inarray, outarray);
659  }
660 }
661 
666 {
667  int physTot = m_fields[0]->GetTotPoints();
668 
669  out0 = Array<OneD, NekDouble>(physTot, 0.0);
670  out1 = Array<OneD, NekDouble>(physTot, 0.0);
671  out2 = Array<OneD, NekDouble>(physTot, 0.0);
672 
673  Vmath::Vcopy(physTot, m_coords[0], 1, out0, 1);
674  Vmath::Vcopy(physTot, m_coords[1], 1, out1, 1);
675  Vmath::Vcopy(physTot, m_coords[2], 1, out2, 1);
676 }
677 
679  Array<OneD, Array<OneD, NekDouble> > &outarray)
680 {
681  int physTot = m_fields[0]->GetTotPoints();
682 
683  for(int i = 0; i < m_nConvectiveFields; ++i)
684  {
685  outarray[i] = Array<OneD, NekDouble>(physTot, 0.0);
686  Vmath::Vcopy(physTot, m_coordsVel[i], 1, outarray[i], 1);
687  }
688 }
689 
691  const Array<OneD, Array<OneD, NekDouble> > &inarray,
692  Array<OneD, NekDouble> &outarray)
693 {
694  int physTot = m_fields[0]->GetTotPoints();
695 
696  outarray = Array<OneD, NekDouble>(physTot, 0.0);
697  if ( !HasConstantJacobian() )
698  {
699  // Set wavespace to false and store current value
700  bool wavespace = m_fields[0]->GetWaveSpace();
701  m_fields[0]->SetWaveSpace(false);
702 
703  // Get Mapping Jacobian
704  Array<OneD, NekDouble> Jac(physTot, 0.0);
705  GetJacobian(Jac);
706 
707  // Calculate inarray . grad(Jac)
708  Array<OneD, NekDouble> wk(physTot, 0.0);
709  for(int i = 0; i < m_nConvectiveFields; ++i)
710  {
711  m_fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[i],
712  Jac, wk);
713  Vmath::Vvtvp(physTot, inarray[i], 1, wk, 1,
714  outarray, 1, outarray, 1);
715  }
716  m_fields[0]->SetWaveSpace(wavespace);
717  }
718 }
719 
721  const Array<OneD, Array<OneD, NekDouble> > &inarray,
722  Array<OneD, Array<OneD, NekDouble> > &outarray)
723 {
724  int physTot = m_fields[0]->GetTotPoints();
725  int nvel = m_nConvectiveFields;
726 
727  Array<OneD, Array<OneD, NekDouble> > g(nvel*nvel);
728 
729  GetMetricTensor(g);
730 
731  for (int i=0; i< nvel; i++)
732  {
733  outarray[i] = Array<OneD, NekDouble> (physTot, 0.0);
734  for (int j=0; j< nvel; j++)
735  {
736  Vmath::Vvtvp(physTot, g[i*nvel+j], 1, inarray[j], 1,
737  outarray[i], 1,
738  outarray[i], 1);
739  }
740  }
741 }
742 
744  const Array<OneD, Array<OneD, NekDouble> > &inarray,
745  Array<OneD, Array<OneD, NekDouble> > &outarray)
746 {
747  int physTot = m_fields[0]->GetTotPoints();
748  int nvel = m_nConvectiveFields;
749 
750  Array<OneD, Array<OneD, NekDouble> > g(nvel*nvel);
751 
753 
754  for (int i=0; i< nvel; i++)
755  {
756  outarray[i] = Array<OneD, NekDouble> (physTot, 0.0);
757  for (int j=0; j< nvel; j++)
758  {
759  Vmath::Vvtvp(physTot, g[i*nvel+j], 1, inarray[j], 1,
760  outarray[i], 1,
761  outarray[i], 1);
762  }
763  }
764 }
765 
767  const Array<OneD, Array<OneD, NekDouble> > &inarray,
768  Array<OneD, NekDouble> &outarray)
769 {
770  int physTot = m_fields[0]->GetTotPoints();
771  Array<OneD, NekDouble> wk(physTot, 0.0);
772 
773  Vmath::Zero(physTot, outarray, 1);
774 
775  // Set wavespace to false and store current value
776  bool wavespace = m_fields[0]->GetWaveSpace();
777  m_fields[0]->SetWaveSpace(false);
778 
779  // Get Mapping Jacobian
780  Array<OneD, NekDouble> Jac(physTot, 0.0);
781  GetJacobian(Jac);
782 
783  for(int i = 0; i < m_nConvectiveFields; ++i)
784  {
785  Vmath::Vmul(physTot,Jac, 1, inarray[i], 1, wk, 1); // J*Ui
786  m_fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[i],
787  wk, wk); // (J*Ui)_i
788  Vmath::Vadd(physTot, wk, 1, outarray, 1, outarray, 1);
789  }
790  Vmath::Vdiv(physTot,outarray,1,Jac,1,outarray,1); //1/J*(J*Ui)_i
791 
792  m_fields[0]->SetWaveSpace(wavespace);
793 }
794 
796  const Array<OneD, Array<OneD, NekDouble> > &inarray,
797  Array<OneD, Array<OneD, NekDouble> > &outarray,
798  const NekDouble alpha)
799 {
800  int physTot = m_fields[0]->GetTotPoints();
801  int nvel = m_nConvectiveFields;
802 
804 
805  // Set wavespace to false and store current value
806  bool wavespace = m_fields[0]->GetWaveSpace();
807  m_fields[0]->SetWaveSpace(false);
808 
809  // Calculate vector gradient wk2 = u^i_(,k) = du^i/dx^k + {i,jk}*u^j
811  for (int i=0; i< nvel; i++)
812  {
813  if(nvel == 2)
814  {
815  m_fields[0]->PhysDeriv(inarray[i],
816  m_wk2[i*nvel+0],
817  m_wk2[i*nvel+1]);
818  }
819  else
820  {
821  m_fields[0]->PhysDeriv(inarray[i],
822  m_wk2[i*nvel+0],
823  m_wk2[i*nvel+1],
824  m_wk2[i*nvel+2]);
825  }
826  for (int k=0; k< nvel; k++)
827  {
828  Vmath::Vadd(physTot,m_wk1[i*nvel+k],1,m_wk2[i*nvel+k],1,
829  m_wk1[i*nvel+k], 1);
830  }
831  }
832  // Calculate wk1 = A^(ij) = g^(jk)*u^i_(,k)
833  for (int i=0; i< nvel; i++)
834  {
835  for (int k=0; k< nvel; k++)
836  {
837  tmp[k] = m_wk1[i*nvel+k];
838  }
839  RaiseIndex(tmp, m_tmp);
840  for (int j=0; j<nvel; j++)
841  {
842  Vmath::Vcopy(physTot, m_tmp[j], 1, m_wk1[i*nvel+j], 1);
843  }
844  }
845  //
846  // Calculate L(U)^i = (A^(ij))_(,j) - alpha*d^2(u^i)/dx^jdx^j
847  //
848 
849  // Step 1 :
850  // d(A^(ij) - alpha*du^i/dx^j)/d(x^j)
851  for (int i=0; i< nvel; i++)
852  {
853  outarray[i] = Array<OneD, NekDouble>(physTot,0.0);
854  for (int j=0; j< nvel; j++)
855  {
856  Vmath::Smul(physTot, alpha, m_wk2[i*nvel+j], 1,
857  m_tmp[0], 1);
858  Vmath::Vsub(physTot, m_wk1[i*nvel+j], 1, m_tmp[0], 1,
859  m_tmp[0], 1);
860 
861  m_fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[j],
862  m_tmp[0],
863  m_tmp[1]);
864  Vmath::Vadd(physTot,outarray[i],1,m_tmp[1],1,outarray[i], 1);
865  }
866  }
867 
868  // Step 2: d(A^(ij))/d(x^j) + {j,pj}*A^(ip)
869  for (int i=0; i< nvel; i++)
870  {
871  for (int p=0; p< nvel; p++)
872  {
873  tmp[p] = m_wk1[i*nvel+p];
874  }
876  for (int j=0; j< nvel; j++)
877  {
878  Vmath::Vadd(physTot,outarray[i],1,m_wk2[j*nvel+j],1,
879  outarray[i], 1);
880  }
881  }
882 
883  // Step 3: d(A^(ij))/d(x^j) + {j,pj}*A^(ip) + {i,pj} A^(pj)
884  for (int j=0; j< nvel; j++)
885  {
886  for (int p=0; p< nvel; p++)
887  {
888  tmp[p] = m_wk1[p*nvel+j];
889  }
891  for (int i=0; i< nvel; i++)
892  {
893  Vmath::Vadd(physTot,outarray[i], 1, m_wk2[i*nvel+j], 1,
894  outarray[i], 1);
895  }
896  }
897 
898  // Restore value of wavespace
899  m_fields[0]->SetWaveSpace(wavespace);
900 }
901 
903  const Array<OneD, Array<OneD, NekDouble> > &inarray,
904  Array<OneD, Array<OneD, NekDouble> > &outarray)
905 {
906  int physTot = m_fields[0]->GetTotPoints();
907  int nvel = m_nConvectiveFields;
908 
909  // Declare variables
910  outarray = Array<OneD, Array<OneD, NekDouble> > (nvel*nvel*nvel);
912  for (int i=0; i< nvel*nvel*nvel; i++)
913  {
914  outarray[i] = Array<OneD, NekDouble>(physTot,0.0);
915  }
916 
917  // Set wavespace to false and store current value
918  bool wavespace = m_fields[0]->GetWaveSpace();
919  m_fields[0]->SetWaveSpace(false);
920 
921  // Calculate vector gradient u^i_(,j) = du^i/dx^j + {i,pj}*u^p
923  for (int i=0; i< nvel; i++)
924  {
925  if (nvel == 2)
926  {
927  m_fields[0]->PhysDeriv(inarray[i],
928  m_wk2[i*nvel+0],
929  m_wk2[i*nvel+1]);
930  }
931  else
932  {
933  m_fields[0]->PhysDeriv(inarray[i],
934  m_wk2[i*nvel+0],
935  m_wk2[i*nvel+1],
936  m_wk2[i*nvel+2]);
937  }
938  for (int j=0; j< nvel; j++)
939  {
940  Vmath::Vadd(physTot,m_wk1[i*nvel+j],1,m_wk2[i*nvel+j],1,
941  m_wk1[i*nvel+j], 1);
942  }
943  }
944 
945  //
946  // Calculate (u^i_,j),k
947  //
948 
949  // Step 1 : d(u^i_,j))/d(x^k)
950  for (int i=0; i< nvel; i++)
951  {
952  for (int j=0; j< nvel; j++)
953  {
954  if (nvel == 2)
955  {
956  m_fields[0]->PhysDeriv(m_wk1[i*nvel+j],
957  outarray[i*nvel*nvel+j*nvel+0],
958  outarray[i*nvel*nvel+j*nvel+1]);
959  }
960  else
961  {
962  m_fields[0]->PhysDeriv(m_wk1[i*nvel+j],
963  outarray[i*nvel*nvel+j*nvel+0],
964  outarray[i*nvel*nvel+j*nvel+1],
965  outarray[i*nvel*nvel+j*nvel+2]);
966  }
967  }
968  }
969 
970  // Step 2: d(u^i_,j)/d(x^k) - {p,jk}*u^i_,p
971  for (int i=0; i< nvel; i++)
972  {
973  for (int p=0; p< nvel; p++)
974  {
975  tmp[p] = m_wk1[i*nvel+p];
976  }
978  for (int j=0; j< nvel; j++)
979  {
980  for (int k=0; k< nvel; k++)
981  {
982  Vmath::Vsub(physTot,outarray[i*nvel*nvel+j*nvel+k],1,
983  m_wk2[j*nvel+k],1,
984  outarray[i*nvel*nvel+j*nvel+k], 1);
985  }
986  }
987  }
988 
989  // Step 3: d(u^i_,j)/d(x^k) - {p,jk}*u^i_,p + {i,pk} u^p_,j
990  for (int j=0; j< nvel; j++)
991  {
992  for (int p=0; p< nvel; p++)
993  {
994  tmp[p] = m_wk1[p*nvel+j];
995  }
997  for (int i=0; i< nvel; i++)
998  {
999  for (int k=0; k< nvel; k++)
1000  {
1001  Vmath::Vadd(physTot,outarray[i*nvel*nvel+j*nvel+k],1,
1002  m_wk2[i*nvel+k],1,
1003  outarray[i*nvel*nvel+j*nvel+k], 1);
1004  }
1005  }
1006  }
1007 
1008  // Restore value of wavespace
1009  m_fields[0]->SetWaveSpace(wavespace);
1010 }
1011 
1013  Array<OneD, Array<OneD, NekDouble> > &inarray,
1014  Array<OneD, Array<OneD, NekDouble> > &outarray,
1015  const bool generalized)
1016 {
1017  int physTot = m_fields[0]->GetTotPoints();
1018  int nvel = m_nConvectiveFields;
1019 
1020  // Set wavespace to false and store current value
1021  bool wavespace = m_fields[0]->GetWaveSpace();
1022  m_fields[0]->SetWaveSpace(false);
1023 
1024  // For implicit treatment of viscous terms, we want the generalized
1025  // curlcurl and for explicit treatment, we want the cartesian one.
1026  if (generalized)
1027  {
1028  // Get the second derivatives u^i_{,jk}
1030  Array<OneD, Array<OneD, NekDouble> > ddU(nvel*nvel*nvel);
1031  gradgradU(inarray, ddU);
1032 
1033  // Raise index to obtain A^{ip}_{k} = g^pj u^i_{,jk}
1034  for (int i = 0; i < nvel; ++i)
1035  {
1036  for (int k = 0; k < nvel; ++k)
1037  {
1038  // Copy to wk
1039  for (int j = 0; j < nvel; ++j)
1040  {
1041  tmp[j] = ddU[i*nvel*nvel+j*nvel+k];
1042  }
1043  RaiseIndex(tmp, m_tmp);
1044  for (int p=0; p<nvel; ++p)
1045  {
1046  Vmath::Vcopy(physTot, m_tmp[p], 1,
1047  ddU[i*nvel*nvel+p*nvel+k], 1);
1048  }
1049  }
1050  }
1051  // The curlcurl is g^ji u^k_{kj} - g^jk u^i_kj = A^{ki}_k - A^{ik}_k
1052  for (int i = 0; i < nvel; ++i)
1053  {
1054  outarray[i] = Array<OneD, NekDouble> (physTot, 0.0);
1055  for (int k = 0; k < nvel; ++k)
1056  {
1057  Vmath::Vadd(physTot, outarray[i], 1,
1058  ddU[k*nvel*nvel+i*nvel+k], 1,
1059  outarray[i], 1);
1060  Vmath::Vsub(physTot, outarray[i], 1,
1061  ddU[i*nvel*nvel+k*nvel+k], 1,
1062  outarray[i], 1);
1063  }
1064  }
1065  }
1066  else
1067  {
1068  m_fields[0]->CurlCurl(inarray, outarray);
1069  }
1070 
1071  // Restore value of wavespace
1072  m_fields[0]->SetWaveSpace(wavespace);
1073 }
1074 
1076 {
1077  int physTot = m_fields[0]->GetTotPoints();
1078  int nvel = m_nConvectiveFields;
1079  int nfields = m_fields.size();
1080  int nbnds = m_fields[0]->GetBndConditions().size();
1081 
1082  // Declare variables
1085 
1086  Array<OneD, bool> isDirichlet(nfields);
1087 
1088  Array<OneD, Array<OneD, NekDouble> > values(nfields);
1089  for (int i=0; i < nfields; i++)
1090  {
1091  values[i] = Array<OneD, NekDouble> (physTot, 0.0);
1092  }
1093 
1096  Array<OneD, Array<OneD, NekDouble> > coordVel(nvel);
1097  for (int i = 0; i< nvel; i++)
1098  {
1099  tmp[i] = Array<OneD, NekDouble> (physTot, 0.0);
1100  tmp2[i] = Array<OneD, NekDouble> (physTot, 0.0);
1101  coordVel[i] = Array<OneD, NekDouble> (physTot, 0.0);
1102  }
1103 
1104  // Get coordinates velocity in transformed system (for MovingBody regions)
1105  GetCoordVelocity(tmp);
1106  ContravarFromCartesian(tmp, coordVel);
1107 
1108  // Get Cartesian coordinates for evaluating boundary conditions
1110  for (int dir=0; dir < 3; dir++)
1111  {
1112  coords[dir] = Array<OneD, NekDouble> (physTot, 0.0);
1113  }
1114  GetCartesianCoordinates(coords[0],coords[1],coords[2]);
1115 
1116  // Loop boundary conditions looking for Dirichlet bc's
1117  for(int n = 0 ; n < nbnds ; ++n)
1118  {
1119  // Evaluate original Dirichlet boundary conditions in whole domain
1120  for (int i = 0; i < nfields; ++i)
1121  {
1122  BndConds = m_fields[i]->GetBndConditions();
1123  BndExp = m_fields[i]->GetBndCondExpansions();
1124  if ( BndConds[n]->GetBoundaryConditionType() ==
1126  {
1127  isDirichlet[i] = true;
1128  // If we have the a velocity component
1129  // check if all vel bc's are also Dirichlet
1130  if ( i<nvel )
1131  {
1132  for (int j = 0; j < nvel; ++j)
1133  {
1134  ASSERTL0(m_fields[j]->GetBndConditions()[n]->
1135  GetBoundaryConditionType() ==
1137  "Mapping only supported when all velocity components have the same type of boundary conditions");
1138  }
1139  }
1140  // Check if bc is time-dependent
1141  ASSERTL0( !BndConds[n]->IsTimeDependent(),
1142  "Time-dependent Dirichlet boundary conditions not supported with mapping yet.");
1143 
1144  // Get boundary condition
1145  LibUtilities::Equation condition =
1146  std::static_pointer_cast<
1148  (BndConds[n])->
1149  m_dirichletCondition;
1150  // Evaluate
1151  condition.Evaluate(coords[0], coords[1], coords[2],
1152  time, values[i]);
1153  }
1154  else
1155  {
1156  isDirichlet[i] = false;
1157  }
1158  }
1159  // Convert velocity vector to transformed system
1160  if ( isDirichlet[0])
1161  {
1162  for (int i = 0; i < nvel; ++i)
1163  {
1164  Vmath::Vcopy(physTot, values[i], 1, tmp[i], 1);
1165  }
1166  ContravarFromCartesian(tmp, tmp2);
1167  for (int i = 0; i < nvel; ++i)
1168  {
1169  Vmath::Vcopy(physTot, tmp2[i], 1, values[i], 1);
1170  }
1171  }
1172 
1173  // Now, project result to boundary
1174  for (int i = 0; i < nfields; ++i)
1175  {
1176  BndConds = m_fields[i]->GetBndConditions();
1177  BndExp = m_fields[i]->GetBndCondExpansions();
1178  if( BndConds[n]->GetUserDefined() =="" ||
1179  BndConds[n]->GetUserDefined() =="MovingBody")
1180  {
1181  m_fields[i]->ExtractPhysToBnd(n,
1182  values[i], BndExp[n]->UpdatePhys());
1183 
1184  // Apply MovingBody correction
1185  if ( (i<nvel) &&
1186  BndConds[n]->GetUserDefined() ==
1187  "MovingBody" )
1188  {
1189  // Get coordinate velocity on boundary
1190  Array<OneD, NekDouble> coordVelBnd(BndExp[n]->GetTotPoints());
1191  m_fields[i]->ExtractPhysToBnd(n, coordVel[i], coordVelBnd);
1192 
1193  // Apply correction
1194  Vmath::Vadd(BndExp[n]->GetTotPoints(),
1195  coordVelBnd, 1,
1196  BndExp[n]->UpdatePhys(), 1,
1197  BndExp[n]->UpdatePhys(), 1);
1198  }
1199  }
1200  }
1201  }
1202 
1203  // Finally, perform FwdTrans in all fields
1204  for (int i = 0; i < m_fields.size(); ++i)
1205  {
1206  // Get boundary condition information
1207  BndConds = m_fields[i]->GetBndConditions();
1208  BndExp = m_fields[i]->GetBndCondExpansions();
1209  for(int n = 0 ; n < BndConds.size(); ++n)
1210  {
1211  if ( BndConds[n]->GetBoundaryConditionType() ==
1213  {
1214  if( BndConds[n]->GetUserDefined() =="" ||
1215  BndConds[n]->GetUserDefined() =="MovingBody")
1216  {
1217  if (m_fields[i]->GetExpType() == MultiRegions::e3DH1D)
1218  {
1219  BndExp[n]->SetWaveSpace(false);
1220  }
1221 
1222  BndExp[n]->FwdTrans_BndConstrained(
1223  BndExp[n]->GetPhys(), BndExp[n]->UpdateCoeffs());
1224  }
1225  }
1226  }
1227  }
1228 }
1229 
1231  const NekDouble time,
1232  const Array<OneD, Array<OneD, NekDouble> > &coords ,
1233  const Array<OneD, Array<OneD, NekDouble> > &coordsVel)
1234 {
1235  if (m_fromFunction)
1236  {
1237  std::string s_FieldStr;
1238  string fieldNames[3] = {"x", "y", "z"};
1239  string velFieldNames[3] = {"vx", "vy", "vz"};
1240  // Check if function from session file defines each component
1241  // and evaluate them, otherwise there is no need to update
1242  // coords
1243  for(int i = 0; i < 3; i++)
1244  {
1245  s_FieldStr = fieldNames[i];
1246  if ( m_session->DefinesFunction(m_funcName, s_FieldStr))
1247  {
1248  EvaluateFunction(m_fields, m_session, s_FieldStr, m_coords[i],
1249  m_funcName, time);
1250  if ( i==2 && m_fields[0]->GetExpType() == MultiRegions::e3DH1D)
1251  {
1252  ASSERTL0 (false,
1253  "3DH1D does not support mapping in the z-direction.");
1254  }
1255  }
1256  s_FieldStr = velFieldNames[i];
1257  if ( m_session->DefinesFunction(m_velFuncName, s_FieldStr))
1258  {
1259  EvaluateFunction(m_fields, m_session, s_FieldStr,
1260  m_coordsVel[i], m_velFuncName, time);
1261  if ( i==2 && m_fields[0]->GetExpType() == MultiRegions::e3DH1D)
1262  {
1263  ASSERTL0 (false,
1264  "3DH1D does not support mapping in the z-direction.");
1265  }
1266  }
1267  }
1268  }
1269  else
1270  {
1271  int physTot = m_fields[0]->GetTotPoints();
1272  int nvel = m_nConvectiveFields;
1273  // Copy coordinates
1274  for(int i = 0; i < 3; i++)
1275  {
1276  Vmath::Vcopy(physTot, coords[i], 1, m_coords[i], 1);
1277  }
1278 
1279  for(int i = 0; i < nvel; i++)
1280  {
1281  Vmath::Vcopy(physTot, coordsVel[i], 1, m_coordsVel[i], 1);
1282  }
1283  }
1284 
1285  // Update the information required by the specific mapping
1286  UpdateGeomInfo();
1287 }
1288 
1289 }
1290 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
bool m_fromFunction
Flag defining if the Mapping is defined by a function.
Definition: Mapping.h:430
int m_nConvectiveFields
Number of velocity components.
Definition: Mapping.h:416
static MappingSharedPtr m_mappingPtr
Definition: Mapping.h:433
virtual GLOBAL_MAPPING_EXPORT void v_GetCartesianCoordinates(Array< OneD, NekDouble > &out0, Array< OneD, NekDouble > &out1, Array< OneD, NekDouble > &out2)
Definition: Mapping.cpp:662
GLOBAL_MAPPING_EXPORT void LowerIndex(const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
Lower index of vector: .
Definition: Mapping.cpp:610
GLOBAL_MAPPING_EXPORT void EvaluateTimeFunction(LibUtilities::SessionReaderSharedPtr pSession, std::string pFieldName, Array< OneD, NekDouble > &pArray, const std::string &pFunctionName, NekDouble pTime=NekDouble(0))
Definition: Mapping.cpp:385
LibUtilities::SessionReaderSharedPtr m_session
Session reader.
Definition: Mapping.h:404
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.
Definition: Mapping.cpp:489
GLOBAL_MAPPING_EXPORT void GetInvMetricTensor(Array< OneD, Array< OneD, NekDouble > > &outarray)
Get the inverse of metric tensor .
Definition: Mapping.h:184
virtual GLOBAL_MAPPING_EXPORT void v_UpdateBCs(const NekDouble time)
Definition: Mapping.cpp:1075
GLOBAL_MAPPING_EXPORT void GetCartesianCoordinates(Array< OneD, NekDouble > &out0, Array< OneD, NekDouble > &out1, Array< OneD, NekDouble > &out2)
Get the Cartesian coordinates in the field.
Definition: Mapping.h:133
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.
Definition: Mapping.h:306
GLOBAL_MAPPING_EXPORT bool IsTimeDependent()
Get flag defining if mapping is time-dependent.
Definition: Mapping.h:340
Array< OneD, Array< OneD, NekDouble > > m_wk2
Definition: Mapping.h:439
virtual GLOBAL_MAPPING_EXPORT void v_CurlCurlField(Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const bool generalized)
Definition: Mapping.cpp:1012
GLOBAL_MAPPING_EXPORT void UpdateGeomInfo()
Recompute the metric terms of the Mapping.
Definition: Mapping.h:396
Array< OneD, Array< OneD, NekDouble > > m_coords
Array with the Cartesian coordinates.
Definition: Mapping.h:410
Array< OneD, Array< OneD, NekDouble > > m_coordsVel
Array with the velocity of the coordinates.
Definition: Mapping.h:412
virtual GLOBAL_MAPPING_EXPORT void v_RaiseIndex(const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
Definition: Mapping.cpp:743
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Definition: Mapping.h:408
std::string m_velFuncName
Name of the function containing the velocity of the coordinates.
Definition: Mapping.h:421
GLOBAL_MAPPING_EXPORT void InitObject(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const TiXmlElement *pMapping)
Initialise the mapping object.
Definition: Mapping.h:75
virtual GLOBAL_MAPPING_EXPORT void v_LowerIndex(const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
Definition: Mapping.cpp:720
GLOBAL_MAPPING_EXPORT void Output(LibUtilities::FieldMetaDataMap &fieldMetaDataMap, const std::string &outname)
Output function called when a chk or fld file is written.
Definition: Mapping.cpp:305
GLOBAL_MAPPING_EXPORT void GetMetricTensor(Array< OneD, Array< OneD, NekDouble > > &outarray)
Get the metric tensor .
Definition: Mapping.h:177
Array< OneD, Array< OneD, NekDouble > > m_wk1
Definition: Mapping.h:438
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.
Definition: Mapping.cpp:549
virtual GLOBAL_MAPPING_EXPORT void v_GetCoordVelocity(Array< OneD, Array< OneD, NekDouble > > &outarray)
Definition: Mapping.cpp:678
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))
Definition: Mapping.cpp:406
virtual GLOBAL_MAPPING_EXPORT void v_gradgradU(const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
Definition: Mapping.cpp:902
virtual GLOBAL_MAPPING_EXPORT void v_ContravarFromCartesian(const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)=0
LibUtilities::FieldIOSharedPtr m_fld
Definition: Mapping.h:406
virtual GLOBAL_MAPPING_EXPORT void v_Divergence(const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, NekDouble > &outarray)
Definition: Mapping.cpp:766
virtual GLOBAL_MAPPING_EXPORT void v_CovarFromCartesian(const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)=0
GLOBAL_MAPPING_EXPORT bool HasConstantJacobian()
Get flag defining if mapping has constant Jacobian.
Definition: Mapping.h:364
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.
Definition: Mapping.cpp:519
GLOBAL_MAPPING_EXPORT void ReplaceField(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields)
Replace the Expansion List used by the mapping.
Definition: Mapping.cpp:245
virtual GLOBAL_MAPPING_EXPORT void v_CovarToCartesian(const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)=0
GLOBAL_MAPPING_EXPORT void RaiseIndex(const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
Raise index of vector: .
Definition: Mapping.cpp:641
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.
Definition: Mapping.h:211
virtual GLOBAL_MAPPING_EXPORT void v_DotGradJacobian(const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, NekDouble > &outarray)
Definition: Mapping.cpp:690
GLOBAL_MAPPING_EXPORT void GetCoordVelocity(Array< OneD, Array< OneD, NekDouble > > &outarray)
Obtain the velocity of the coordinates.
Definition: Mapping.h:244
std::string m_funcName
Name of the function containing the coordinates.
Definition: Mapping.h:419
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.
Definition: Mapping.cpp:268
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.
Definition: Mapping.cpp:579
GLOBAL_MAPPING_EXPORT void GetJacobian(Array< OneD, NekDouble > &outarray)
Get the Jacobian of the transformation.
Definition: Mapping.h:154
virtual GLOBAL_MAPPING_EXPORT void v_VelocityLaplacian(const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble alpha)
Definition: Mapping.cpp:795
virtual GLOBAL_MAPPING_EXPORT void v_ContravarToCartesian(const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)=0
virtual GLOBAL_MAPPING_EXPORT void v_InitObject(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const TiXmlElement *pMapping)
Definition: Mapping.cpp:100
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.
Definition: Mapping.h:229
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)
Definition: Mapping.cpp:1230
Array< OneD, Array< OneD, NekDouble > > m_tmp
Definition: Mapping.h:440
bool m_timeDependent
Flag defining if the Mapping is time-dependent.
Definition: Mapping.h:428
NekDouble Evaluate() const
Definition: Equation.cpp:95
static std::shared_ptr< FieldIO > CreateForFile(const LibUtilities::SessionReaderSharedPtr session, const std::string &filename)
Construct a FieldIO object for a given input filename.
Definition: FieldIO.cpp:226
static std::shared_ptr< FieldIO > CreateDefault(const LibUtilities::SessionReaderSharedPtr session)
Returns an object for the default FieldIO method.
Definition: FieldIO.cpp:195
Provides a generic Factory class.
Definition: NekFactory.hpp:105
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
Definition: NekFactory.hpp:145
GLOBAL_MAPPING_EXPORT typedef std::shared_ptr< Mapping > MappingSharedPtr
A shared pointer to a Mapping object.
Definition: Mapping.h:50
MappingFactory & GetMappingFactory()
Declaration of the mapping factory singleton.
Definition: Mapping.cpp:52
std::shared_ptr< FieldIO > FieldIOSharedPtr
Definition: FieldIO.h:306
std::map< std::string, std::string > FieldMetaDataMap
Definition: FieldIO.h:52
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Equation > EquationSharedPtr
Definition: Equation.h:131
MultiRegions::Direction const DirCartesianMap[]
Definition: ExpList.h:90
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1
double NekDouble
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:192
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:513
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:322
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.
Definition: Vmath.cpp:225
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:257
void Zero(int n, T *x, const int incx)
Zero vector.
Definition: Vmath.cpp:436
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1199
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:372