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