-
Notifications
You must be signed in to change notification settings - Fork 977
Expand file tree
/
Copy pathCVariable.hpp
More file actions
2432 lines (2049 loc) · 86.8 KB
/
CVariable.hpp
File metadata and controls
2432 lines (2049 loc) · 86.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*!
* \file CVariable.hpp
* \brief Declaration and inlines of the parent class for defining problem
variables, function definitions in file <i>CVariable.cpp</i>.
All variables are children of at least this class.
* \author F. Palacios, T. Economon
* \version 8.4.0 "Harrier"
*
* SU2 Project Website: https://su2code.github.io
*
* The SU2 Project is maintained by the SU2 Foundation
* (http://su2foundation.org)
*
* Copyright 2012-2026, SU2 Contributors (cf. AUTHORS.md)
*
* SU2 is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* SU2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with SU2. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "../../../Common/include/parallelization/mpi_structure.hpp"
#include <cmath>
#include <iostream>
#include <cstdlib>
#include "../../../Common/include/CConfig.hpp"
#include "../../../Common/include/containers/container_decorators.hpp"
class CFluidModel;
class CNEMOGas;
/*!
* \class CVariable
* \ingroup Variable
* \brief Main class for defining the variables.
* \author F. Palacios
*/
class CVariable {
protected:
using VectorType = C2DContainer<unsigned long, su2double, StorageType::ColumnMajor, 64, DynamicSize, 1>;
using MatrixType = C2DContainer<unsigned long, su2double, StorageType::RowMajor, 64, DynamicSize, DynamicSize>;
MatrixType Solution; /*!< \brief Solution of the problem. */
MatrixType Solution_Old; /*!< \brief Old solution of the problem R-K. */
MatrixType UserDefinedSource; /*!< \brief User Defined Source of the problem. */
MatrixType External; /*!< \brief External (outer) contribution in discrete adjoint multizone problems. */
su2vector<bool> Non_Physical; /*!< \brief Non-physical points in the solution (force first order). */
su2vector<unsigned short>
Non_Physical_Counter; /*!< \brief Number of consecutive iterations that a point has been treated first-order.
After a specified number of successful reconstructions, the point can be returned to second-order. */
VectorType UnderRelaxation; /*!< \brief Value of the under-relaxation parameter local to the control volume. */
VectorType LocalCFL; /*!< \brief Value of the CFL number local to the control volume. */
MatrixType Solution_time_n; /*!< \brief Solution of the problem at time n for dual-time stepping technique. */
MatrixType Solution_time_n1; /*!< \brief Solution of the problem at time n-1 for dual-time stepping technique. */
VectorType Delta_Time; /*!< \brief Time step. */
VectorType Density_unsteady; /*!< \brief density for unsteady flows. */
VectorType Density_time_n; /*!< \brief density at time n for dual-time stepping technique. */
VectorType Density_time_n1; /*!< \brief density at time n for dual-time stepping technique. */
CVectorOfMatrix Gradient; /*!< \brief Gradient of the solution of the problem. */
C3DDoubleMatrix Rmatrix; /*!< \brief Geometry-based matrix for weighted least squares gradient calculations. */
MatrixType Limiter; /*!< \brief Limiter of the solution of the problem. */
MatrixType Solution_Max; /*!< \brief Max solution for limiter computation. */
MatrixType Solution_Min; /*!< \brief Min solution for limiter computation. */
MatrixType AuxVar; /*!< \brief Auxiliary variable for gradient computation. */
CVectorOfMatrix Grad_AuxVar; /*!< \brief Gradient of the auxiliary variables of the problem. */
VectorType Max_Lambda_Inv; /*!< \brief Maximun inviscid eingenvalue. */
VectorType Max_Lambda_Visc; /*!< \brief Maximun viscous eingenvalue. */
VectorType Lambda; /*!< \brief Value of the eingenvalue. */
VectorType Sensor; /*!< \brief Pressure sensor for high order central scheme and Roe dissipation. */
MatrixType Undivided_Laplacian; /*!< \brief Undivided laplacian of the solution. */
MatrixType Res_TruncError; /*!< \brief Truncation error for multigrid cycle. */
MatrixType Residual_Old; /*!< \brief Auxiliary structure for residual smoothing. */
MatrixType Residual_Sum; /*!< \brief Auxiliary structure for residual smoothing. */
MatrixType Solution_BGS_k; /*!< \brief Old solution container for BGS iterations. */
su2matrix<AD::Identifier> AD_InputIndex; /*!< \brief Indices of Solution variables in the adjoint vector before solver iteration. */
su2matrix<AD::Identifier> AD_OutputIndex; /*!< \brief Indices of Solution variables in the adjoint vector after solver iteration. */
VectorType SolutionExtra; /*!< \brief Stores adjoint solution for extra solution variables.
Currently only streamwise periodic pressure-drop for massflow prescribed flows. */
VectorType ExternalExtra; /*!< \brief External storage for the adjoint value (i.e. for the OF mainly */
VectorType SolutionExtra_BGS_k; /*!< \brief Intermediate storage, enables cross term extraction as that is also pushed to Solution. */
protected:
unsigned long nPoint = 0; /*!< \brief Number of points in the domain. */
unsigned long nDim = 0; /*!< \brief Number of dimension of the problem. */
unsigned long nVar = 0; /*!< \brief Number of variables of the problem. */
unsigned long nPrimVar = 0; /*!< \brief Number of primitive variables. */
unsigned long nPrimVarGrad = 0; /*!< \brief Number of primitives for which a gradient is computed. */
unsigned long nSecondaryVar = 0; /*!< \brief Number of secondary variables. */
unsigned long nSecondaryVarGrad = 0; /*!< \brief Number of secondaries for which a gradient is computed. */
unsigned long nAuxVar = 0; /*!< \brief Number of auxiliary variables. */
/*--- Only allow default construction by derived classes. ---*/
CVariable() = default;
inline static void AssertOverride() {
assert(false && "A base method of CVariable was used, but it should have been overridden by the derived class.");
}
void RegisterContainer(bool input, su2activematrix& variable, su2matrix<AD::Identifier>* ad_index = nullptr) {
const auto nPoint = variable.rows();
SU2_OMP_FOR_STAT(roundUpDiv(nPoint,omp_get_num_threads()))
for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) {
for(unsigned long iVar=0; iVar<variable.cols(); ++iVar) {
if (input) AD::RegisterInput(variable(iPoint,iVar));
else AD::RegisterOutput(variable(iPoint,iVar));
if (ad_index) AD::SetIndex((*ad_index)(iPoint,iVar), variable(iPoint,iVar));
}
}
END_SU2_OMP_FOR
}
void RegisterContainer(bool input, su2activematrix& variable, su2matrix<AD::Identifier>& ad_index) {
RegisterContainer(input, variable, &ad_index);
}
void RegisterContainer(bool input, su2activevector& variable, su2vector<AD::Identifier>* ad_index = nullptr) {
const auto nPoint = variable.rows();
SU2_OMP_FOR_STAT(roundUpDiv(nPoint,omp_get_num_threads()))
for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) {
if (input) AD::RegisterInput(variable(iPoint));
else AD::RegisterOutput(variable(iPoint));
if (ad_index) AD::SetIndex((*ad_index)(iPoint), variable(iPoint));
}
END_SU2_OMP_FOR
}
public:
/*--- Disable copy and assignment. ---*/
CVariable(const CVariable&) = delete;
CVariable(CVariable&&) = delete;
CVariable& operator= (const CVariable&) = delete;
CVariable& operator= (CVariable&&) = delete;
/*!
* \overload
* \param[in] npoint - Number of points/nodes/vertices in the domain.
* \param[in] nvar - Number of variables of the problem.
* \param[in] config - Definition of the particular problem.
*/
CVariable(unsigned long npoint, unsigned long nvar, const CConfig *config);
/*!
* \overload
* \param[in] npoint - Number of points/nodes/vertices in the domain.
* \param[in] ndim - Number of dimensions of the problem.
* \param[in] nvar - Number of variables of the problem.
* \param[in] config - Definition of the particular problem.
* \param[in] adjoint - True if derived class is an adjoint variable.
*/
CVariable(unsigned long npoint, unsigned long ndim, unsigned long nvar, const CConfig *config, bool adjoint = false);
/*!
* \brief Destructor of the class.
*/
virtual ~CVariable() = default;
/*!
* \brief Get the number of auxiliary variables.
*/
inline unsigned long GetnAuxVar() const { return nAuxVar; }
/*!
* \brief Set the value of the solution, all variables.
* \param[in] iPoint - Point index.
* \param[in] solution - Solution of the problem.
*/
inline void SetSolution(unsigned long iPoint, const su2double *solution) {
for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution(iPoint,iVar) = solution[iVar];
}
/*!
* \brief Set the value of the solution, one variable.
* \param[in] iPoint - Point index.
* \param[in] iVar - Index of the variable.
* \param[in] solution - Value of the solution for the index <i>iVar</i>.
*/
inline void SetSolution(unsigned long iPoint, unsigned long iVar, su2double solution) { Solution(iPoint,iVar) = solution; }
/*!
* \brief Add the value of the solution vector to the previous solution (incremental approach).
* \param[in] iPoint - Point index.
* \param[in] iVar - Index of the variable.
* \param[in] solution - Value of the solution for the index <i>iVar</i>.
*/
inline void Add_DeltaSolution(unsigned long iPoint, unsigned long iVar, su2double solution) { Solution(iPoint,iVar) += solution; }
/*!
* \brief Set the value of the non-physical point.
* \param[in] iPoint - Point index.
* \param[in] value - identification of the non-physical point.
*/
inline void SetNon_Physical(unsigned long iPoint, bool val_value) {
if (val_value) {
Non_Physical(iPoint) = val_value;
Non_Physical_Counter(iPoint) = 0;
} else {
Non_Physical_Counter(iPoint)++;
if (Non_Physical_Counter(iPoint) > 20) {
Non_Physical(iPoint) = false;
}
}
}
/*!
* \brief Get the value of the non-physical boolean at a point.
* \param[in] iPoint - Point index.
* \return Value of the Non-physical point.
*/
inline bool GetNon_Physical(unsigned long iPoint) { return Non_Physical(iPoint); }
/*!
* \brief Get the solution.
* \param[in] iPoint - Point index.
* \param[in] iVar - Index of the variable.
* \return Value of the solution for the index <i>iVar</i>.
*/
inline su2double GetSolution(unsigned long iPoint, unsigned long iVar) const { return Solution(iPoint,iVar); }
/*!
* \brief Get the old solution of the problem (Runge-Kutta method)
* \param[in] iPoint - Point index.
* \param[in] iVar - Index of the variable.
* \return Pointer to the old solution vector.
*/
inline su2double GetSolution_Old(unsigned long iPoint, unsigned long iVar) const { return Solution_Old(iPoint,iVar); }
/*!
* \brief Set the value of the old solution.
* \param[in] iPoint - Point index.
* \param[in] solution_old - Pointer to the residual vector.
*/
inline void SetSolution_Old(unsigned long iPoint, const su2double *solution_old) {
for (unsigned long iVar = 0; iVar < nVar; iVar++)
Solution_Old(iPoint,iVar) = solution_old[iVar];
}
/*!
* \overload
* \param[in] iVar - Index of the variable.
* \param[in] iPoint - Point index.
* \param[in] solution_old - Value of the old solution for the index <i>iVar</i>.
*/
inline void SetSolution_Old(unsigned long iPoint, unsigned long iVar, su2double solution_old) { Solution_Old(iPoint,iVar) = solution_old; }
/*!
* \brief Set old variables to the value of the current variables.
*/
void Set_OldSolution();
/*!
* \brief Set variables to the value of the old variables.
*/
void Set_Solution();
/*!
* \brief Set the variable solution at time n.
*/
void Set_Solution_time_n();
/*!
* \brief Set the variable solution at time n-1.
*/
void Set_Solution_time_n1();
/*!
* \brief Set the density at time n.
*/
void SetDensity_time_n();
/*!
* \brief Set the density at time n-1.
*/
void SetDensity_time_n1();
/*!
* \brief Set the variable solution at time n.
* \param[in] iPoint - Point index.
*/
inline void Set_Solution_time_n(unsigned long iPoint, const su2double* val_sol) {
for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_time_n(iPoint,iVar) = val_sol[iVar];
}
/*!
* \brief Set the variable solution at time n-1.
* \param[in] iPoint - Point index.
*/
inline void Set_Solution_time_n1(unsigned long iPoint, const su2double* val_sol) {
for (unsigned long iVar = 0; iVar < nVar; iVar++)
Solution_time_n1(iPoint,iVar) = val_sol[iVar];
}
/*!
* \brief Set the variable solution at time n.
* \param[in] iPoint - Point index.
*/
inline void Set_Solution_time_n(unsigned long iPoint, unsigned long iVar, su2double val_sol) {
Solution_time_n(iPoint,iVar) = val_sol;
}
/*!
* \brief Set the variable solution at time n-1.
* \param[in] iPoint - Point index.
*/
inline void Set_Solution_time_n1(unsigned long iPoint, unsigned long iVar, su2double val_sol) {
Solution_time_n1(iPoint,iVar) = val_sol;
}
inline void SetDensity_time_n(unsigned long iPoint, su2double val) {
Density_time_n[iPoint] = val;
}
inline void SetDensity_time_n1(unsigned long iPoint, su2double val) {
Density_time_n1[iPoint] = val;
}
inline void SetDensity_unsteady(unsigned long iPoint, su2double val) {
Density_unsteady[iPoint] = val;
}
/*!
* \brief Virtual Member. Specify a vector to set the velocity components of the solution.
* Multiplied by density for compressible cases.
* \param[in] iPoint - Point index.
* \param[in] val_vector - Pointer to the vector.
*/
inline virtual void SetVelSolutionVector(unsigned long iPoint, const su2double *val_vector) { }
/*!
* \brief Add a value to the solution.
* \param[in] iPoint - Point index.
* \param[in] iVar - Number of the variable.
* \param[in] solution - Value that we want to add to the solution.
*/
inline void AddSolution(unsigned long iPoint, unsigned long iVar, su2double solution) {
Solution(iPoint, iVar) = Solution_Old(iPoint, iVar) + solution;
}
/*!
* \brief Add a value to the solution.
* \param[in] iPoint - Point index.
* \param[in] solution - Value that we want to add to the solution.
*/
inline void AddSolution(unsigned long iPoint, const su2double *solution) {
for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution(iPoint, iVar) += solution[iVar];
}
/*!
* \brief A virtual member.
* \param[in] iPoint - Point index.
* \param[in] iVar - Index of the variable.
* \return Pointer to the old solution vector.
*/
inline virtual su2double GetSolution_New(unsigned long iPoint, unsigned long iVar) const { return 0.0; }
/*!
* \brief A virtual member.
* \param[in] iPoint - Point index.
*/
inline virtual su2double GetRoe_Dissipation(unsigned long iPoint) const { return 0.0; }
/*!
* \brief A virtual member.
* \param[in] iPoint - Point index.
*/
inline virtual void SetRoe_Dissipation(unsigned long iPoint, su2double val_dissipation) {}
/*!
* \brief A virtual member.
* \param[in] iPoint - Point index.
*/
inline virtual void SetRoe_Dissipation_FD(unsigned long iPoint, su2double val_wall_dist) {}
/*!
* \brief A virtual member.
* \param[in] iPoint - Point index.
* \param[in] val_delta - A scalar measure of the grid size
* \param[in] val_const_DES - The DES constant (C_DES)
*/
inline virtual void SetRoe_Dissipation_NTS(unsigned long iPoint, su2double val_delta, su2double val_const_DES) {}
/*!
* \brief A virtual member.
* \param[in] iPoint - Point index.
*/
inline virtual su2double GetDES_LengthScale(unsigned long iPoint) const { return 0.0; }
/*!
* \brief A virtual member.
* \param[in] iPoint - Point index.
*/
inline virtual void SetDES_LengthScale(unsigned long iPoint, su2double val_des_lengthscale) {}
/*!
* \brief A virtual member.
* \param[in] iPoint - Point index.
*/
virtual void SetSolution_New() {}
/*!
* \brief Set external contributions to zero.
*/
void SetExternalZero();
/*!
* \brief Set Dual-time derivative contributions to the external.
*/
inline virtual void Set_External_To_DualTimeDer() { SetExternalZero(); }
/*!
* \brief A virtual member.
* \param[in] iPoint - Point index.
* \param[in] iVar - Number of the variable.
* \param[in] solution - Value that we want to add to the solution.
*/
inline virtual void AddSolution_New(unsigned long iPoint, unsigned long iVar, su2double solution) {}
/*!
* \brief Add a value to the External vector.
* \param[in] iPoint - Point index.
* \param[in] val_sol - vector that has to be added component-wise
*/
inline void Add_External(unsigned long iPoint, const su2double* val_sol) {
for(unsigned long iVar = 0; iVar < nVar; iVar++) External(iPoint,iVar) += val_sol[iVar];
}
/*!
* \brief Store the adjoint solution of the extra adjoint into the external container.
*/
void Set_ExternalExtra_To_SolutionExtra() {
assert(SolutionExtra.size() == ExternalExtra.size());
for (auto iEntry = 0ul; iEntry < SolutionExtra.size(); iEntry++)
ExternalExtra[iEntry] = SolutionExtra[iEntry];
}
/*!
* \brief Add the external contribution to the solution for the extra adjoint solutions.
*/
void Add_ExternalExtra_To_SolutionExtra() {
assert(SolutionExtra.size() == ExternalExtra.size());
for (auto iEntry = 0ul; iEntry < SolutionExtra.size(); iEntry++)
SolutionExtra[iEntry] += ExternalExtra[iEntry];
}
/*!
* \brief Return the extra adjoint solution.
* \return Reference to extra adjoint solution.
*/
inline VectorType& GetSolutionExtra() { return SolutionExtra; }
inline const VectorType& GetSolutionExtra() const { return SolutionExtra; }
/*!
* \brief Update the variables using a conservative format.
* \param[in] iPoint - Point index.
* \param[in] iVar - Index of the variable.
* \param[in] solution - Value of the solution change.
* \param[in] lowerlimit - Lower value for Solution clipping.
* \param[in] upperlimit - Upper value for Solution clipping.
* \param[in] Sol2Conservative - Factor multiplied to Solution to get transported variable.
* \param[in] Sol2Conservative_old - Factor multiplied to Solution to get transported variable, of the previous Iteration.
*/
inline void AddClippedSolution(unsigned long iPoint, unsigned long iVar, su2double solution,
su2double lowerlimit, su2double upperlimit,
su2double Sol2Conservative = 1.0, su2double Sol2Conservative_old = 1.0) {
su2double val_new = (Solution_Old(iPoint,iVar)*Sol2Conservative_old + solution)/Sol2Conservative;
Solution(iPoint,iVar) = min(max(val_new, lowerlimit), upperlimit);
}
/*!
* \brief Get the entire solution of the problem.
* \return Reference to the solution matrix.
*/
inline const MatrixType& GetSolution() const { return Solution; }
inline MatrixType& GetSolution() { return Solution; }
/*!
* \brief Get the solution of the problem.
* \param[in] iPoint - Point index.
* \return Pointer to the solution vector.
*/
inline su2double *GetSolution(unsigned long iPoint) { return Solution[iPoint]; }
/*!
* \brief Get the entire User Define Source of the problem.
* \return Reference to the solution matrix.
*/
inline const MatrixType& GetUserDefinedSource() const { return UserDefinedSource; }
inline MatrixType& GetUserDefinedSource() { return UserDefinedSource; }
/*!
* \brief Get the old solution of the problem (Runge-Kutta method)
* \param[in] iPoint - Point index.
* \return Pointer to the old solution vector.
*/
inline su2double *GetSolution_Old(unsigned long iPoint) { return Solution_Old[iPoint]; }
/*!
* \brief Get the external contributions of the problem.
* \param[in] iPoint - Point index.
* \return Pointer to the External row for iPoint.
*/
inline const su2double *Get_External(unsigned long iPoint) const { return External[iPoint]; }
inline const MatrixType& Get_External() const { return External; }
/*!
* \brief Get the solution at time n.
* \param[in] iPoint - Point index.
* \return Pointer to the solution (at time n) vector.
*/
inline su2double *GetSolution_time_n(unsigned long iPoint) { return Solution_time_n[iPoint]; }
inline MatrixType& GetSolution_time_n() { return Solution_time_n; }
/*!
* \brief Get the solution at time n-1.
* \param[in] iPoint - Point index.
* \return Pointer to the solution (at time n-1) vector.
*/
inline su2double *GetSolution_time_n1(unsigned long iPoint) { return Solution_time_n1[iPoint]; }
inline MatrixType& GetSolution_time_n1() { return Solution_time_n1; }
/*!
* \brief Get the solution at time n.
* \param[in] iPoint - Point index.
* \return Pointer to the solution (at time n) vector.
*/
inline su2double GetDensity_time_n(unsigned long iPoint) const { return Density_time_n[iPoint]; }
inline VectorType& GetDensity_time_n() { return Density_time_n; }
/*!
* \brief Get the solution at time n.
* \param[in] iPoint - Point index.
* \return Pointer to the solution (at time n) vector.
*/
inline su2double GetDensity_time_n1(unsigned long iPoint) const { return Density_time_n1[iPoint]; }
inline VectorType& GetDensity_time_n1() { return Density_time_n1; }
/*!
* \brief Get the density.
* \param[in] iPoint - Point index.
* \return Pointer to the solution (at time n) vector.
*/
inline su2double GetDensity_unsteady(unsigned long iPoint) const { return Density_unsteady[iPoint]; }
inline VectorType& GetDensity_unsteady() { return Density_unsteady; }
/*!
* \brief Set the value of the old residual.
* \param[in] iPoint - Point index.
* \param[in] val_residual_old - Pointer to the residual vector.
*/
inline void SetResidual_Old(unsigned long iPoint, const su2double *val_residual_old) {
for (unsigned long iVar = 0; iVar < nVar; iVar++)
Residual_Old(iPoint,iVar) = val_residual_old[iVar];
}
/*!
* \brief Add a value to the summed residual vector.
* \param[in] iPoint - Point index.
* \param[in] val_residual - Pointer to the residual vector.
*/
inline void AddResidual_Sum(unsigned long iPoint, const su2double *val_residual) {
for (unsigned long iVar = 0; iVar < nVar; iVar++)
Residual_Sum(iPoint,iVar) += val_residual[iVar];
}
/*!
* \brief Set summed residual vector to zero value.
*/
inline void SetResidualSumZero(unsigned long iPoint) {
for (unsigned long iVar = 0; iVar < nVar; iVar++) Residual_Sum(iPoint,iVar) = 0.0;
}
/*!
* \brief Get the value of the summed residual.
* \param[in] iPoint - Point index.
* \return Pointer to the summed residual.
*/
inline su2double *GetResidual_Sum(unsigned long iPoint) { return Residual_Sum[iPoint]; }
/*!
* \brief Get the value of the old residual.
* \param[in] iPoint - Point index.
* \return Pointer to the old residual.
*/
inline su2double *GetResidual_Old(unsigned long iPoint) { return Residual_Old[iPoint]; }
/*!
* \brief Get the value of the summed residual.
* \param[in] iPoint - Point index.
* \param[in] val_residual - Pointer to the summed residual.
*/
inline void GetResidual_Sum(unsigned long iPoint, su2double *val_residual) const {
for (unsigned long iVar = 0; iVar < nVar; iVar++)
val_residual[iVar] = Residual_Sum(iPoint,iVar);
}
/*!
* \brief Set the value of the under-relaxation parameter for the current control volume (CV).
* \param[in] iPoint - Point index.
* \param[in] val_under_relaxation - the input value of the under-relaxation parameter for this CV.
*/
inline void SetUnderRelaxation(unsigned long iPoint, su2double val_under_relaxation) { UnderRelaxation(iPoint) = val_under_relaxation; }
/*!
* \brief Get the value of the under-relaxation parameter for the current control volume (CV).
* \param[in] iPoint - Point index.
* \return Value of the under-relaxation parameter for this CV.
*/
inline su2double GetUnderRelaxation(unsigned long iPoint) const { return UnderRelaxation(iPoint); }
/*!
* \brief Set the value of the local CFL number for the current control volume (CV).
* \param[in] iPoint - Point index.
* \param[in] val_cfl - the input value of the local CFL number for this CV.
*/
inline void SetLocalCFL(unsigned long iPoint, su2double val_cfl) { LocalCFL(iPoint) = val_cfl; }
/*!
* \brief Get the value of the local CFL number for the current control volume (CV).
* \param[in] iPoint - Point index.
* \return Value of the local CFL number for this CV.
*/
inline su2double GetLocalCFL(unsigned long iPoint) const { return LocalCFL(iPoint); }
/*!
* \brief Get the entire Aux matrix of the problem.
* \return Reference to the aux var matrix.
*/
inline const MatrixType& GetAuxVar(void) const { return AuxVar; }
/*!
* \brief Get the Aux var value at Point i, variable j.
*/
inline su2double GetAuxVar(unsigned long iPoint, unsigned long iVar = 0) const { return AuxVar(iPoint,iVar); }
/*!
* \brief Set auxiliary variables.
* \param[in] iPoint - Point index.
* \param[in] iVar - Varriable indexs
* \param[in] val_auxvar - Value of the auxiliar variable.
*/
inline void SetAuxVar(unsigned long iPoint, unsigned long iVar, const su2double auxvar) {
AuxVar(iPoint,iVar) = auxvar;
}
/*!
* \brief Set value of auxillary gradients.
* \param[in] iPoint - Point index.
* \param[in] iVar - Index of the variable.
* \param[in] iDim - Index of the dimension.
* \param[in] value - Value of the gradient.
*/
inline void SetAuxVarGradient(unsigned long iPoint, unsigned long iVar, unsigned long iDim, su2double value) {
Grad_AuxVar(iPoint,iVar,iDim) = value;
}
/*!
* \brief Get the gradient of the auxilary variables.
* \return Reference to gradient.
*/
inline CVectorOfMatrix& GetAuxVarGradient(void) { return Grad_AuxVar; }
/*!
* \brief Get the value of the auxilliary gradient.
* \param[in] iPoint - Point index.
* \param[in] iVar - Index of the variable.
* \param[in] iDim - Index of the dimension.
* \return Value of the solution gradient.
*/
inline su2double GetAuxVarGradient(unsigned long iPoint, unsigned long iVar, unsigned long iDim) const {
return Grad_AuxVar(iPoint,iVar,iDim);
}
/*!
* \brief Get the value of the auxilliary gradient.
* \param[in] iPoint - Point index.
* \return Value of the solution gradient.
*/
inline CMatrixView<su2double> GetAuxVarGradient(unsigned long iPoint) {
return Grad_AuxVar[iPoint];
}
/*!
* \brief Add a value to the truncation error.
* \param[in] iPoint - Point index.
* \param[in] val_truncation_error - Value that we want to add to the truncation error.
*/
inline void AddRes_TruncError(unsigned long iPoint, const su2double *val_truncation_error) {
for (unsigned long iVar = 0; iVar < nVar; iVar++)
Res_TruncError(iPoint, iVar) += val_truncation_error[iVar];
}
/*!
* \brief Subtract a value to the truncation error.
* \param[in] iPoint - Point index.
* \param[in] val_truncation_error - Value that we want to subtract to the truncation error.
*/
inline void SubtractRes_TruncError(unsigned long iPoint, const su2double *val_truncation_error) {
for (unsigned long iVar = 0; iVar < nVar; iVar++)
Res_TruncError(iPoint, iVar) -= val_truncation_error[iVar];
}
/*!
* \brief Set the truncation error to zero.
* \param[in] iPoint - Point index.
*/
inline void SetRes_TruncErrorZero(unsigned long iPoint) {
for (unsigned long iVar = 0; iVar < nVar; iVar++) Res_TruncError(iPoint, iVar) = 0.0;
}
/*!
* \brief Set the truncation error to zero.
* \param[in] iPoint - Point index.
*/
inline void SetVal_ResTruncError_Zero(unsigned long iPoint, unsigned long iVar) {Res_TruncError(iPoint, iVar) = 0.0;}
/*!
* \brief Set the momentum part of the truncation error to zero.
* \param[in] iPoint - Point index.
*/
inline virtual void SetVel_ResTruncError_Zero(unsigned long iPoint) { }
/*!
* \brief Set the velocity of the truncation error to zero.
* \param[in] iPoint - Point index.
*/
inline void SetEnergy_ResTruncError_Zero(unsigned long iPoint) { Res_TruncError(iPoint,nDim+1) = 0.0;}
/*!
* \brief Get the truncation error.
* \param[in] iPoint - Point index.
* \return Pointer to the truncation error.
*/
inline su2double *GetResTruncError(unsigned long iPoint) { return Res_TruncError[iPoint]; }
/*!
* \brief Get the truncation error.
* \param[in] iPoint - Point index.
* \param[in] val_trunc_error - Pointer to the truncation error.
*/
inline void GetResTruncError(unsigned long iPoint, su2double *val_trunc_error) const {
for (unsigned long iVar = 0; iVar < nVar; iVar++)
val_trunc_error[iVar] = Res_TruncError(iPoint, iVar);
}
/*!
* \brief Set the truncation error.
* \param[in] iPoint - Point index.
* \param[in] val_trunc_error - Pointer to the truncation error.
*/
inline void SetResTruncError(unsigned long iPoint, su2double *val_trunc_error) {
for (unsigned long iVar = 0; iVar < nVar; iVar++)
Res_TruncError(iPoint, iVar) = val_trunc_error[iVar];
}
/*!
* \brief Set the gradient of the solution.
* \param[in] iPoint - Point index.
* \param[in] gradient - Gradient of the solution.
*/
inline void SetGradient(unsigned long iPoint, su2double **gradient) {
for (unsigned long iVar = 0; iVar < nVar; iVar++)
for (unsigned long iDim = 0; iDim < nDim; iDim++)
Gradient(iPoint,iVar,iDim) = gradient[iVar][iDim];
}
/*!
* \brief Get the gradient of the entire solution.
* \return Reference to gradient.
*/
inline CVectorOfMatrix& GetGradient(void) { return Gradient; }
/*!
* \brief Get the value of the solution gradient.
* \param[in] iPoint - Point index.
* \return Value of the gradient solution.
*/
inline CMatrixView<su2double> GetGradient(unsigned long iPoint) { return Gradient[iPoint]; }
/*!
* \brief Get the value of the solution gradient.
* \param[in] iPoint - Point index.
* \param[in] iVar - Index of the variable.
* \param[in] iDim - Index of the dimension.
* \return Value of the solution gradient.
*/
inline su2double GetGradient(unsigned long iPoint, unsigned long iVar, unsigned long iDim) const { return Gradient(iPoint,iVar,iDim); }
/*!
* \brief Add <i>value</i> to the Rmatrix for least squares gradient calculations.
* \param[in] iPoint - Point index.
* \param[in] iDim - Index of the dimension.
* \param[in] jDim - Index of the dimension.
* \param[in] value - Value of the Rmatrix entry.
*/
inline void AddRmatrix(unsigned long iPoint, unsigned long iDim, unsigned long jDim, su2double value) { Rmatrix(iPoint,iDim,jDim) += value; }
/*!
* \brief Get the value of the Rmatrix entry for least squares gradient calculations.
* \param[in] iPoint - Point index.
* \param[in] iDim - Index of the dimension.
* \param[in] jDim - Index of the dimension.
* \return Value of the Rmatrix entry.
*/
inline su2double GetRmatrix(unsigned long iPoint, unsigned long iDim, unsigned long jDim) const { return Rmatrix(iPoint,iDim,jDim); }
/*!
* \brief Get the value Rmatrix for the entire domain.
* \return Reference to the Rmatrix.
*/
inline C3DDoubleMatrix& GetRmatrix(void) { return Rmatrix; }
/*!
* \brief Get the slope limiter.
* \return Reference to the limiters vector.
*/
inline MatrixType& GetLimiter(void) { return Limiter; }
/*!
* \brief Get the value of the slope limiter.
* \param[in] iPoint - Point index.
* \return Pointer to the limiters vector.
*/
inline su2double *GetLimiter(unsigned long iPoint) { return Limiter[iPoint]; }
/*!
* \brief Get the value of the slope limiter.
* \param[in] iPoint - Point index.
* \param[in] iVar - Index of the variable.
* \return Value of the limiter vector for the variable <i>iVar</i>.
*/
inline su2double GetLimiter(unsigned long iPoint, unsigned long iVar) const { return Limiter(iPoint,iVar); }
/*!
* \brief Get the min solution.
* \return Value of the min solution for the domain.
*/
inline MatrixType& GetSolution_Max() { return Solution_Max; }
inline const MatrixType& GetSolution_Max() const { return Solution_Max; }
/*!
* \brief Get the min solution.
* \return Value of the min solution for the domain.
*/
inline MatrixType& GetSolution_Min() { return Solution_Min; }
inline const MatrixType& GetSolution_Min() const { return Solution_Min; }
/*!
* \brief Set the value of the time step.
* \param[in] iPoint - Point index.
* \param[in] val_delta_time - Value of the time step.
*/
inline void SetDelta_Time(unsigned long iPoint, su2double val_delta_time) { Delta_Time(iPoint) = val_delta_time; }
/*!
* \brief Get the value of the time step.
* \param[in] iPoint - Point index.
* \return Value of the time step.
*/
inline su2double GetDelta_Time(unsigned long iPoint) const {return Delta_Time(iPoint); }
/*!
* \brief Set the value of the maximum eigenvalue for the inviscid terms of the PDE.
* \param[in] iPoint - Point index.
* \param[in] val_max_lambda - Value of the maximum eigenvalue for the inviscid terms of the PDE.
*/
inline void SetMax_Lambda_Inv(unsigned long iPoint, su2double val_max_lambda) { Max_Lambda_Inv(iPoint) = val_max_lambda; }
/*!
* \brief Set the value of the maximum eigenvalue for the viscous terms of the PDE.
* \param[in] iPoint - Point index.
* \param[in] val_max_lambda - Value of the maximum eigenvalue for the viscous terms of the PDE.
*/
inline void SetMax_Lambda_Visc(unsigned long iPoint, su2double val_max_lambda) { Max_Lambda_Visc(iPoint) = val_max_lambda; }
/*!
* \brief Add a value to the maximum eigenvalue for the inviscid terms of the PDE.
* \param[in] iPoint - Point index.
* \param[in] val_max_lambda - Value of the maximum eigenvalue for the inviscid terms of the PDE.
*/
inline void AddMax_Lambda_Inv(unsigned long iPoint, su2double val_max_lambda) { Max_Lambda_Inv(iPoint) += val_max_lambda; }
/*!
* \brief Add a value to the maximum eigenvalue for the viscous terms of the PDE.
* \param[in] iPoint - Point index.
* \param[in] val_max_lambda - Value of the maximum eigenvalue for the viscous terms of the PDE.
*/
inline void AddMax_Lambda_Visc(unsigned long iPoint, su2double val_max_lambda) { Max_Lambda_Visc(iPoint) += val_max_lambda; }
/*!
* \brief Get the value of the maximum eigenvalue for the inviscid terms of the PDE.
* \param[in] iPoint - Point index.
* \return the value of the maximum eigenvalue for the inviscid terms of the PDE.
*/
inline su2double GetMax_Lambda_Inv(unsigned long iPoint) const { return Max_Lambda_Inv(iPoint); }
/*!
* \brief Get the value of the maximum eigenvalue for the viscous terms of the PDE.
* \param[in] iPoint - Point index.
* \return the value of the maximum eigenvalue for the viscous terms of the PDE.
*/
inline su2double GetMax_Lambda_Visc(unsigned long iPoint) const { return Max_Lambda_Visc(iPoint); }
/*!
* \brief Set the value of the spectral radius.
* \param[in] iPoint - Point index.
* \param[in] val_lambda - Value of the spectral radius.
*/
inline void SetLambda(unsigned long iPoint, su2double val_lambda) { Lambda(iPoint) = val_lambda; }
/*!
* \brief Add the value of the spectral radius.
* \param[in] iPoint - Point index.
* \param[in] val_lambda - Value of the spectral radius.
*/
inline void AddLambda(unsigned long iPoint, su2double val_lambda) { Lambda(iPoint) += val_lambda; }
/*!
* \brief Get the value of the spectral radius.
* \param[in] iPoint - Point index.
* \return Value of the spectral radius.
*/
inline su2double GetLambda(unsigned long iPoint) const { return Lambda(iPoint); }
inline const VectorType& GetLambda() const { return Lambda; }
/*!
* \brief Set pressure sensor.
* \param[in] iPoint - Point index.
* \param[in] val_sensor - Value of the pressure sensor.
*/
inline void SetSensor(unsigned long iPoint, su2double val_sensor) { Sensor(iPoint) = val_sensor; }
/*!
* \brief Get the pressure sensor.
* \param[in] iPoint - Point index.
* \return Value of the pressure sensor.
*/
inline su2double GetSensor(unsigned long iPoint) const { return Sensor(iPoint); }
inline const VectorType& GetSensor() const { return Sensor; }
/*!
* \brief Increment the value of the undivided laplacian of the solution.
* \param[in] iPoint - Point index.
* \param[in] iVar - Variable of the undivided laplacian.
* \param[in] val_und_lapl - Value of the undivided solution.
*/
inline void AddUnd_Lapl(unsigned long iPoint, unsigned long iVar, su2double val_und_lapl) {
Undivided_Laplacian(iPoint, iVar) += val_und_lapl;
}
/*!
* \brief Set a value to the undivided laplacian.
* \param[in] iPoint - Point index.
* \param[in] iVar - Variable of the undivided laplacian.
* \param[in] val_und_lapl - Value of the undivided laplacian.
*/
inline void SetUnd_Lapl(unsigned long iPoint, unsigned long iVar, su2double val_und_lapl) {
Undivided_Laplacian(iPoint, iVar) = val_und_lapl;
}
/*!
* \brief Get the undivided laplacian of the solution.
* \param[in] iPoint - Point index.
* \return Pointer to the undivided laplacian vector.
*/
inline su2double *GetUndivided_Laplacian(unsigned long iPoint) { return Undivided_Laplacian[iPoint]; }
/*!
* \brief Get the undivided laplacian of the solution.