Skip to content

Commit c8f8cf5

Browse files
V2.0.03 (#213)
* std::filesystem compatibility (#210) * Improve and debug slices (#211) * CLN: cleanup redefinition of idfx::randm in planet tests (#212) * Improve lookup table (#214) * fix slice VTK outputs when they are at a boundary (#215) * use SlopeLimiter class's PPM implementation (#218) * fix an overflow in dump restart routines (#219) * fix a bug identified in gcc 9.3.0 (#220) * add documentation for global IdefixArrays (#221) --------- Co-authored-by: Clément Robert <cr52@protonmail.com>
1 parent 6947116 commit c8f8cf5

File tree

25 files changed

+437
-231
lines changed

25 files changed

+437
-231
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [2.0.3] 2023-11-24
8+
### Changed
9+
- fix and improve slice VTK outputs (#211)
10+
- improve std::filesystem compatibility with old stdlibc++ (#210)
11+
- cleanup planet test (#212)
12+
- allow the use of IdefixHostArrays as inputs for the LookupTable class (#214)
13+
- use Felker & Stone (2018) PPM scheme when using HIGH_ORDER_FARGO in place of Colella & Woodward (1984) (#218).
14+
- fix a bug that could result in segfaults when reading a restart dump, in particular in 1D problems with MPI (#219).
15+
- fix a bug preventing compilation on gcc 9.3.0 (#220)
16+
717
## [2.0.2] 2023-11-6
818
### Changed
919
- fixed compilation issues with gcc 8.x (#205)

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ set (CMAKE_CXX_STANDARD 17)
44

55
set(Idefix_VERSION_MAJOR 2)
66
set(Idefix_VERSION_MINOR 0)
7-
set(Idefix_VERSION_PATCH 01)
7+
set(Idefix_VERSION_PATCH 03)
88

9-
project (idefix VERSION 1.0.0)
9+
project (idefix VERSION 2.0.03)
1010
option(Idefix_MHD "enable MHD" OFF)
1111
option(Idefix_MPI "enable Message Passing Interface parallelisation" OFF)
1212
option(Idefix_HIGH_ORDER_FARGO "Force Fargo to use a PPM reconstruction scheme" OFF)

doc/source/faq.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ The compilation stops while compiling Kokkos with ``/usr/include/stdlib.h(58): e
3939
When using the Intel compiler on a Mac Intel, I get a linking error involving the ``SharedAllocationRecordIvvE18t_tracking_enabledE`` symbol.
4040
This is a known bug of the Intel Mac compiler with Kokkos. Apparently Intel has decided not to fix it. Check the issue on the `Kokkos git page <https://github.com/kokkos/kokkos/issues/1959>`_.
4141

42+
I get an error during *Idefix* link that says there are undefined symbols to std::filesystem
43+
This is a known bug/limitation of the stdlibc++ provided with gcc8 that does not include C++17 filesystem extensions.
44+
While *Idefix* auto-detects gcc8 when it is used as the main compiler, it still misses the cases when another compiler
45+
(like Clang or Intel) is used with gcc8 as a backend.
46+
You should try to clear up CMakeCache.txt and explicitely add the required link library when calling cmake as in
47+
``LDFLAGS=-lstdc++fs cmake $IDEFIX_DIR ...```
48+
4249
Execution
4350
---------
4451

doc/source/reference/setup.cpp.rst

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,3 +395,80 @@ User-defined analysis
395395

396396
User-defined analysis and outputs can be coded in the ``setup.cpp`` file. Follow the
397397
guidelines in :ref:`output`.
398+
399+
I need a global IdefixArray for my Setup
400+
-----------------------------------------
401+
402+
There are situation where you will need one or several global IdefixArrays that can be accessed from different
403+
functions, e.g. the ``Initflow`` method and the user-defined boundary conditions.
404+
405+
It is important to understand that IdefixArrays (equivalent to ``Kokkos::view`` that are references to memory chunks)
406+
are automatically dealocated when all of the IdefixArrays refereing to that memory chunk have been deleted. This deletion happens either
407+
implicitly (by a closing scope) in which case the objects contained in the scope are all deleted automatically,
408+
or explicitly (through a new/delete pair).
409+
410+
If you define an IdefixArray in the global scope, it is deleted when the program terminates. Hence deallocation should happen then.
411+
Except that, according to `Kokkos documentation <https://kokkos.github.io/kokkos-core-wiki/ProgrammingGuide/Initialization.html#finalization>`_, we
412+
need to call ``Kokkos::finalize`` before the program terminates and this ``finalize`` should be done once all of
413+
the Kokkos objects have been deleted (including IdefixArray). While *Idefix* makes sure that all of its objects (including the user's ``Setup``) are being deleted before calling ``finalize``,
414+
a simple IdefixArray in the global scope will not be explicitely deleted, and will typically lead to the following error:
415+
416+
.. code-block:: bash
417+
418+
terminate called after throwing an instance of 'std::runtime_error'
419+
what(): Kokkos allocation "MyAwesomeArray" is being deallocated after Kokkos::finalize was called
420+
421+
The way to avoid this is to explicitely delete the object when you don't need it anymore. The cleanest way to do this for a setup is to define a "container" class,
422+
containing all of the arrays you will need in the global scope, and just have a global pointer to an instance of this class, that you eventually delete
423+
(and which deletes all of the arrays it contains automatically). More explicitely:
424+
425+
#. start with a declaration of a class container (that we name MyGlobalClass in this example) and a global pointer to a class instance (note that you can put as many arrays as you want in the class)
426+
427+
.. code-block:: c++
428+
429+
// Class declaration
430+
class MyGlobalClass {
431+
public:
432+
// Class constructor
433+
MyGlobalClass(DataBlock &data) {
434+
//allocate some memory for the array the class contains
435+
this->array1 = IdefixArray3D<real>("MyAwesomeArray",data.np_tot[KDIR], data.np_tot[JDIR], data.np_tot[IDIR]);
436+
}
437+
438+
// array1, member of the class
439+
IdefixArray3D<real> array1;
440+
};
441+
442+
// A global class instance named "myGlobals"
443+
MyGlobalClass *myGlobals;
444+
445+
#. initialise your global object in the Setup constructor (this will aumatically allocate the array it contains thanks to the class constructor we have defined):
446+
447+
.. code-block:: c++
448+
449+
Setup::Setup(....) {
450+
...
451+
myGlobals = new MyGlobalClass(data);
452+
...
453+
}
454+
455+
#. to avoid the error message above, don't forget to delete the object on exit in the Setup destructor
456+
457+
.. code-block:: c++
458+
459+
Setup::~Setup(....) {
460+
...
461+
delete myGlobals;
462+
...
463+
}
464+
465+
#. and finally, use your array when you need it:
466+
467+
.. code-block:: c++
468+
469+
MyXXXXFunction(....) {
470+
// Shallow copy the global array
471+
IdefixArray3D<real> array = myGlobals->array1;
472+
// Do stuff
473+
....
474+
}

src/dataBlock/fargo.hpp

Lines changed: 21 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
#include "mpi.hpp"
1515
#endif
1616

17-
// Forward class hydro declaration
1817
#include "physics.hpp"
18+
#include "slopeLimiter.hpp"
19+
20+
// Forward class hydro declaration
1921
template <typename Phys> class Fluid;
2022
using Hydro = Fluid<DefaultPhysics>;
2123
class DataBlock;
@@ -85,15 +87,6 @@ class Fargo {
8587
#endif
8688

8789
#ifdef HIGH_ORDER_FARGO
88-
KOKKOS_FORCEINLINE_FUNCTION real PPMLim(real dvp, real dvm) {
89-
if(dvp*dvm >0.0) {
90-
real dqc = 0.5*(dvp+dvm);
91-
real d2q = 2.0*( fabs(dvp) < fabs(dvm) ? dvp : dvm);
92-
return( fabs(d2q) < fabs(dqc) ? d2q : dqc);
93-
}
94-
return(ZERO_F);
95-
}
96-
9790
KOKKOS_INLINE_FUNCTION real FargoFlux(const IdefixArray4D<real> &Vin, int n, int k, int j, int i,
9891
int so, int ds, int sbeg, real eps,
9992
bool haveDomainDecomposition) {
@@ -108,51 +101,36 @@ KOKKOS_INLINE_FUNCTION real FargoFlux(const IdefixArray4D<real> &Vin, int n, int
108101
int som2 = som1-1;
109102
if(!haveDomainDecomposition && (som2-sbeg< 0 )) som2 = som2+ds;
110103

111-
real dqm2,dqm1,dqp1,dqp2, q0,qm1, qp1;
104+
real q0,qm1, qp1, qm2, qp2;
112105
#if GEOMETRY == CARTESIAN || GEOMETRY == POLAR
113106
q0 = Vin(n,k,so,i);
114107
qm1 = Vin(n,k,som1,i);
115108
qp1 = Vin(n,k,sop1,i);
116-
dqm2 = qm1 - Vin(n,k,som2,i);
117-
dqm1 = q0 - qm1;
118-
dqp1 = qp1 - q0;
119-
dqp2 = Vin(n,k,sop2,i) - qp1;
109+
qm2 = Vin(n,k,som2,i);
110+
qp2 = Vin(n,k,sop2,i);
120111
#elif GEOMETRY == SPHERICAL
121112
q0 = Vin(n,so,j,i);
122113
qm1 = Vin(n,som1,j,i);
123114
qp1 = Vin(n,sop1,j,i);
124-
dqm2 = qm1 - Vin(n,som2,j,i);
125-
dqm1 = q0 - qm1;
126-
dqp1 = qp1 - q0;
127-
dqp2 = Vin(n,sop2,j,i) - qp1;
115+
qm2 = Vin(n,som2,j,i);
116+
qp2 = Vin(n,sop2,j,i);
128117
#endif
129-
// slope limited values around the reference point
130-
real dqlm = PPMLim(dqm1,dqm2);
131-
real dql0 = PPMLim(dqp1,dqm1);
132-
real dqlp = PPMLim(dqp2,dqp1);
133-
134-
real dqp = 0.5 * dqp1 - (dqlp - dql0) / 6.0;
135-
real dqm = -0.5 * dqm1 - (dql0 - dqlm) / 6.0;
136-
137-
if(dqp*dqm>0.0) {
138-
dqp = dqm = 0.0;
139-
} else {
140-
if(FABS(dqp) >= 2.0*FABS(dqm)) dqp = -2.0*dqm;
141-
if(FABS(dqm) >= 2.0*FABS(dqp)) dqm = -2.0*dqp;
142-
}
143118

144-
real qp = q0 + dqp;
145-
real qm = q0 + dqm;
119+
real qp, qm;
120+
SlopeLimiter<>::getPPMStates(qm2,qm1,q0,qp1,qp2, qm, qp);
146121

147-
real dqc = dqp - dqm;
148-
real d2q = dqp + dqm;
122+
real dqp = qp-q0;
123+
real dqm = qm-q0;
149124

150-
real F;
151-
if(eps > 0.0) {
152-
F = eps*(qp - 0.5*eps*(dqc + d2q*(3.0 - 2.0*eps)));
153-
} else {
154-
F = eps*(qm - 0.5*eps*(dqc - d2q*(3.0 + 2.0*eps)));
155-
}
125+
real dqc = dqp - dqm;
126+
real d2q = dqp + dqm;
127+
128+
real F;
129+
if(eps > 0.0) {
130+
F = eps*(qp - 0.5*eps*(dqc + d2q*(3.0 - 2.0*eps)));
131+
} else {
132+
F = eps*(qm - 0.5*eps*(dqc - d2q*(3.0 + 2.0*eps)));
133+
}
156134

157135
return(F);
158136
}

src/fluid/braginskii/bragThermalDiffusion.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ class BragThermalDiffusion {
7373

7474
template <typename Phys>
7575
BragThermalDiffusion::BragThermalDiffusion(Input &input, Grid &grid, Fluid<Phys> *hydroin):
76-
Vc{hydroin->Vc},
77-
Vs{hydroin->Vs},
78-
dMax{hydroin->dMax},
79-
eos{hydroin->eos.get()},
80-
data{hydroin->data},
81-
status{hydroin->bragThermalDiffusionStatus} {
76+
Vc(hydroin->Vc),
77+
Vs(hydroin->Vs),
78+
dMax(hydroin->dMax),
79+
eos(hydroin->eos.get()),
80+
data(hydroin->data),
81+
status(hydroin->bragThermalDiffusionStatus) {
8282
idfx::pushRegion("BragThermalDiffusion::BragThermalDiffusion");
8383

8484
if(input.CheckEntry("Hydro","bragTDiffusion")>=0) {

src/fluid/braginskii/bragViscosity.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ class BragViscosity {
6767

6868
template<typename Phys>
6969
BragViscosity::BragViscosity(Input &input, Grid &grid, Fluid<Phys> *hydroin):
70-
Vc{hydroin->Vc},
71-
Vs{hydroin->Vs},
72-
dMax{hydroin->dMax},
73-
status{hydroin->bragViscosityStatus} {
70+
Vc(hydroin->Vc),
71+
Vs(hydroin->Vs),
72+
dMax(hydroin->dMax),
73+
status(hydroin->bragViscosityStatus) {
7474
idfx::pushRegion("BragViscosity::BragViscosity");
7575
// Save the parent hydro object
7676
this->data = hydroin->data;

src/fluid/thermalDiffusion.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ class ThermalDiffusion {
6464

6565
template <typename Phys>
6666
ThermalDiffusion::ThermalDiffusion(Input &input, Grid &grid, Fluid<Phys> *hydroin):
67-
Vc{hydroin->Vc},
68-
dMax{hydroin->dMax},
69-
eos{hydroin->eos.get()},
70-
data{hydroin->data},
71-
status{hydroin->thermalDiffusionStatus} {
67+
Vc(hydroin->Vc),
68+
dMax(hydroin->dMax),
69+
eos(hydroin->eos.get()),
70+
data(hydroin->data),
71+
status(hydroin->thermalDiffusionStatus) {
7272
idfx::pushRegion("ThermalDiffusion::ThermalDiffusion");
7373

7474
if(status.status == Constant) {

src/fluid/viscosity.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ class Viscosity {
6666

6767
template<typename Phys>
6868
Viscosity::Viscosity(Input &input, Grid &grid, Fluid<Phys> *hydroin):
69-
Vc{hydroin->Vc},
70-
dMax{hydroin->dMax},
71-
status{hydroin->viscosityStatus} {
69+
Vc(hydroin->Vc),
70+
dMax(hydroin->dMax),
71+
status(hydroin->viscosityStatus) {
7272
idfx::pushRegion("Viscosity::Viscosity");
7373
// Save the parent hydro object
7474
this->data = hydroin->data;

0 commit comments

Comments
 (0)