Skip to content

Commit 1aa7baa

Browse files
committed
Start the 3.0 development cycle. Port to C++-20
1 parent 12b4e32 commit 1aa7baa

38 files changed

+298
-1578
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.0)
33
include(cmake/modules/mgis.cmake)
44
project("mfront-generic-interface")
55

6-
set(CMAKE_CXX_STANDARD 17)
6+
set(CMAKE_CXX_STANDARD 20)
77
set(CXX_STANDARD_REQUIRED ON)
88

99
# portable-build

bindings/c/src/MaterialDataManager.cxx

+4-4
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ mgis_status mgis_bv_material_data_manager_initializer_bind_tangent_operator(
4747
"invalid tangent operator");
4848
}
4949
try {
50-
d->K = mgis::span<mgis::real>(K, s);
50+
d->K = std::span<mgis::real>(K, s);
5151
} catch (...) {
5252
return mgis_handle_cxx_exception();
5353
}
@@ -69,7 +69,7 @@ mgis_status mgis_bv_material_data_manager_initializer_bind_speed_of_sound(
6969
"invalid tangent operator");
7070
}
7171
try {
72-
d->speed_of_sound = mgis::span<mgis::real>(p, s);
72+
d->speed_of_sound = std::span<mgis::real>(p, s);
7373
} catch (...) {
7474
return mgis_handle_cxx_exception();
7575
}
@@ -201,7 +201,7 @@ mgis_bv_material_data_manager_use_external_array_of_tangent_operator_blocks(
201201
"null behaviour");
202202
}
203203
try {
204-
d->useExternalArrayOfTangentOperatorBlocks(mgis::span<mgis::real>(p, n));
204+
d->useExternalArrayOfTangentOperatorBlocks(std::span<mgis::real>(p, n));
205205
} catch (...) {
206206
return mgis_handle_cxx_exception();
207207
}
@@ -251,7 +251,7 @@ mgis_status mgis_bv_material_data_manager_use_external_array_of_speed_of_sounds(
251251
"null behaviour");
252252
}
253253
try {
254-
d->useExternalArrayOfSpeedOfSounds(mgis::span<mgis::real>(p, n));
254+
d->useExternalArrayOfSpeedOfSounds(std::span<mgis::real>(p, n));
255255
} catch (...) {
256256
return mgis_handle_cxx_exception();
257257
}

bindings/c/src/MaterialStateManager.cxx

+15-20
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ mgis_status mgis_bv_material_state_manager_initializer_bind_gradients(
3131
"(memory pointer is null)");
3232
}
3333
try {
34-
i->gradients = mgis::span<mgis::real>(p, s);
34+
i->gradients = std::span<mgis::real>(p, s);
3535
} catch (...) {
3636
return mgis_handle_cxx_exception();
3737
}
@@ -54,7 +54,7 @@ mgis_bv_material_state_manager_initializer_bind_thermodynamic_forces(
5454
"(memory pointer is null)");
5555
}
5656
try {
57-
i->thermodynamic_forces = mgis::span<mgis::real>(p, s);
57+
i->thermodynamic_forces = std::span<mgis::real>(p, s);
5858
} catch (...) {
5959
return mgis_handle_cxx_exception();
6060
}
@@ -78,7 +78,7 @@ mgis_bv_material_state_manager_initializer_bind_internal_state_variables(
7878
"(memory pointer is null)");
7979
}
8080
try {
81-
i->internal_state_variables = mgis::span<mgis::real>(p, s);
81+
i->internal_state_variables = std::span<mgis::real>(p, s);
8282
} catch (...) {
8383
return mgis_handle_cxx_exception();
8484
}
@@ -101,7 +101,7 @@ mgis_status mgis_bv_material_state_manager_initializer_bind_stored_energies(
101101
"(memory pointer is null)");
102102
}
103103
try {
104-
i->stored_energies = mgis::span<mgis::real>(p, s);
104+
i->stored_energies = std::span<mgis::real>(p, s);
105105
} catch (...) {
106106
return mgis_handle_cxx_exception();
107107
}
@@ -124,7 +124,7 @@ mgis_status mgis_bv_material_state_manager_initializer_bind_dissipated_energies(
124124
"(memory pointer is null)");
125125
}
126126
try {
127-
i->dissipated_energies = mgis::span<mgis::real>(p, s);
127+
i->dissipated_energies = std::span<mgis::real>(p, s);
128128
} catch (...) {
129129
return mgis_handle_cxx_exception();
130130
}
@@ -232,7 +232,6 @@ mgis_status mgis_bv_material_state_manager_set_uniform_material_property(
232232
const char* const n,
233233
mgis_real* const v,
234234
const mgis_bv_MaterialStateManagerStorageMode s) {
235-
using index_type = mgis::span<mgis::real>::index_type;
236235
if (m == nullptr) {
237236
return mgis_report_failure("null state manager");
238237
}
@@ -243,11 +242,11 @@ mgis_status mgis_bv_material_state_manager_set_uniform_material_property(
243242
const auto& mp = getVariable(m->b.mps, n);
244243
const auto mpsize = getVariableSize(mp, m->b.hypothesis);
245244
if (s == MGIS_BV_LOCAL_STORAGE) {
246-
setMaterialProperty(*m, n, {v, static_cast<index_type>(mpsize)},
245+
setMaterialProperty(*m, n, {v, static_cast<mgis_size_type>(mpsize)},
247246
mgis::behaviour::MaterialStateManager::LOCAL_STORAGE);
248247
} else {
249248
setMaterialProperty(
250-
*m, n, {v, static_cast<index_type>(mpsize)},
249+
*m, n, {v, static_cast<mgis_size_type>(mpsize)},
251250
mgis::behaviour::MaterialStateManager::EXTERNAL_STORAGE);
252251
}
253252
} catch (...) {
@@ -261,7 +260,6 @@ mgis_status mgis_bv_material_state_manager_set_non_uniform_material_property(
261260
const char* const n,
262261
mgis_real* const v,
263262
const mgis_bv_MaterialStateManagerStorageMode s) {
264-
using index_type = mgis::span<mgis::real>::index_type;
265263
if (m == nullptr) {
266264
return mgis_report_failure("null state manager");
267265
}
@@ -272,11 +270,11 @@ mgis_status mgis_bv_material_state_manager_set_non_uniform_material_property(
272270
const auto& mp = getVariable(m->b.mps, n);
273271
const auto mpsize = getVariableSize(mp, m->b.hypothesis);
274272
if (s == MGIS_BV_LOCAL_STORAGE) {
275-
setMaterialProperty(*m, n, {v, static_cast<index_type>(m->n * mpsize)},
273+
setMaterialProperty(*m, n, {v, static_cast<mgis_size_type>(m->n * mpsize)},
276274
mgis::behaviour::MaterialStateManager::LOCAL_STORAGE);
277275
} else {
278276
setMaterialProperty(
279-
*m, n, {v, static_cast<index_type>(m->n * mpsize)},
277+
*m, n, {v, static_cast<mgis_size_type>(m->n * mpsize)},
280278
mgis::behaviour::MaterialStateManager::EXTERNAL_STORAGE);
281279
}
282280
} catch (...) {
@@ -336,7 +334,6 @@ mgis_status mgis_bv_material_state_manager_set_non_uniform_mass_density(
336334
mgis_bv_MaterialStateManager* const m,
337335
mgis_real* const v,
338336
const mgis_bv_MaterialStateManagerStorageMode s) {
339-
using index_type = mgis::span<mgis::real>::index_type;
340337
if (m == nullptr) {
341338
return mgis_report_failure("null state manager");
342339
}
@@ -345,10 +342,10 @@ mgis_status mgis_bv_material_state_manager_set_non_uniform_mass_density(
345342
}
346343
try {
347344
if (s == MGIS_BV_LOCAL_STORAGE) {
348-
setMassDensity(*m, {v, static_cast<index_type>(m->n)},
345+
setMassDensity(*m, {v, static_cast<mgis_size_type>(m->n)},
349346
mgis::behaviour::MaterialStateManager::LOCAL_STORAGE);
350347
} else {
351-
setMassDensity(*m, {v, static_cast<index_type>(m->n)},
348+
setMassDensity(*m, {v, static_cast<mgis_size_type>(m->n)},
352349
mgis::behaviour::MaterialStateManager::EXTERNAL_STORAGE);
353350
}
354351
} catch (...) {
@@ -410,7 +407,6 @@ mgis_bv_material_state_manager_set_uniform_external_state_variable(
410407
const char* const n,
411408
mgis_real* const v,
412409
const mgis_bv_MaterialStateManagerStorageMode s) {
413-
using index_type = mgis::span<mgis::real>::index_type;
414410
if (m == nullptr) {
415411
return mgis_report_failure("null state manager");
416412
}
@@ -422,11 +418,11 @@ mgis_bv_material_state_manager_set_uniform_external_state_variable(
422418
const auto esvsize = getVariableSize(esv, m->b.hypothesis);
423419
if (s == MGIS_BV_LOCAL_STORAGE) {
424420
setExternalStateVariable(
425-
*m, n, {v, static_cast<index_type>(esvsize)},
421+
*m, n, {v, static_cast<mgis_size_type>(esvsize)},
426422
mgis::behaviour::MaterialStateManager::LOCAL_STORAGE);
427423
} else {
428424
setExternalStateVariable(
429-
*m, n, {v, static_cast<index_type>(esvsize)},
425+
*m, n, {v, static_cast<mgis_size_type>(esvsize)},
430426
mgis::behaviour::MaterialStateManager::EXTERNAL_STORAGE);
431427
}
432428
} catch (...) {
@@ -441,7 +437,6 @@ mgis_bv_material_state_manager_set_non_uniform_external_state_variable(
441437
const char* const n,
442438
mgis_real* const v,
443439
const mgis_bv_MaterialStateManagerStorageMode s) {
444-
using index_type = mgis::span<mgis::real>::index_type;
445440
if (m == nullptr) {
446441
return mgis_report_failure("null state manager");
447442
}
@@ -453,11 +448,11 @@ mgis_bv_material_state_manager_set_non_uniform_external_state_variable(
453448
const auto esvsize = getVariableSize(esv, m->b.hypothesis);
454449
if (s == MGIS_BV_LOCAL_STORAGE) {
455450
setExternalStateVariable(
456-
*m, n, {v, static_cast<index_type>(esvsize * m->n)},
451+
*m, n, {v, static_cast<mgis_size_type>(esvsize * m->n)},
457452
mgis::behaviour::MaterialStateManager::LOCAL_STORAGE);
458453
} else {
459454
setExternalStateVariable(
460-
*m, n, {v, static_cast<index_type>(esvsize * m->n)},
455+
*m, n, {v, static_cast<mgis_size_type>(esvsize * m->n)},
461456
mgis::behaviour::MaterialStateManager::EXTERNAL_STORAGE);
462457
}
463458
} catch (...) {

bindings/c/src/State.cxx

+2-2
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ mgis_status mgis_bv_state_set_external_state_variable_by_name(
330330
try {
331331
const auto& ev = getVariable(s->b.esvs, n);
332332
const auto es = getVariableSize(ev, s->b.hypothesis);
333-
setExternalStateVariable(*s, n, mgis::span<const mgis::real>(v, es));
333+
setExternalStateVariable(*s, n, std::span<const mgis::real>(v, es));
334334
} catch (...) {
335335
return mgis_handle_cxx_exception();
336336
}
@@ -379,7 +379,7 @@ mgis_status mgis_bv_state_set_external_state_variable_by_offset(
379379
const mgis_real* const v,
380380
const mgis_size_type vs) {
381381
try {
382-
setExternalStateVariable(*s, o, mgis::span<const mgis::real>(v, vs));
382+
setExternalStateVariable(*s, o, std::span<const mgis::real>(v, vs));
383383
} catch (...) {
384384
return mgis_handle_cxx_exception();
385385
}

bindings/fenics/tests/src/ElasticityUniaxialTensileTestImposedStrain3D-exx.cxx

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ int main() {
137137
mgis::size_type steps = 10;
138138
double dt = 0.1;
139139
while (step < steps) {
140-
auto extract = [](const mgis::span<double> v) {
140+
auto extract = [](const std::span<double> v) {
141141
return std::array<double, 6>{v[0], v[1], v[2], v[3], v[4], v[5]};
142142
};
143143
m.setTimeIncrement(dt);

bindings/fenics/tests/src/ElasticityUniaxialTensileTestImposedStrain3D-exy.cxx

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ int main() {
140140
mgis::size_type steps = 10;
141141
double dt = 0.1;
142142
while (step < steps) {
143-
auto extract = [](const mgis::span<double>& v) {
143+
auto extract = [](const std::span<double>& v) {
144144
return std::array<double, 6>{v[0], v[1], v[2], v[3], v[4], v[5]};
145145
};
146146
m.setTimeIncrement(dt);

bindings/fenics/tests/src/ElasticityUniaxialTensileTestImposedStrain3D-exz.cxx

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ int main() {
141141
mgis::size_type steps = 10;
142142
double dt = 0.1;
143143
while (step < steps) {
144-
auto extract = [](const mgis::span<double>& v) {
144+
auto extract = [](const std::span<double>& v) {
145145
return std::array<double, 6>{v[0], v[1], v[2], v[3], v[4], v[5]};
146146
};
147147
m.setTimeIncrement(dt);

bindings/fenics/tests/src/ElasticityUniaxialTensileTestImposedStrain3D-eyy.cxx

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ int main() {
136136
mgis::size_type steps = 10;
137137
double dt = 0.1;
138138
while (step < steps) {
139-
auto extract = [](const mgis::span<double>& v) {
139+
auto extract = [](const std::span<double>& v) {
140140
return std::array<double, 6>{v[0], v[1], v[2], v[3], v[4], v[5]};
141141
};
142142
m.setTimeIncrement(dt);

bindings/fenics/tests/src/ElasticityUniaxialTensileTestImposedStrain3D-eyz.cxx

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ int main() {
141141
mgis::size_type steps = 10;
142142
double dt = 0.1;
143143
while (step < steps) {
144-
auto extract = [](const mgis::span<double>& v) {
144+
auto extract = [](const std::span<double>& v) {
145145
return std::array<double, 6>{v[0], v[1], v[2], v[3], v[4], v[5]};
146146
};
147147
m.setTimeIncrement(dt);

bindings/fenics/tests/src/ElasticityUniaxialTensileTestImposedStrain3D-ezz.cxx

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ int main() {
137137
mgis::size_type steps = 10;
138138
double dt = 0.1;
139139
while (step < steps) {
140-
auto extract = [](const mgis::span<double>& v) {
140+
auto extract = [](const std::span<double>& v) {
141141
return std::array<double, 6>{v[0], v[1], v[2], v[3], v[4], v[5]};
142142
};
143143
m.setTimeIncrement(dt);

bindings/fenics/tests/src/ElasticityUniaxialTensileTestImposedStrainPlaneStress-exx.cxx

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ int main() {
135135
mgis::size_type steps = 10;
136136
double dt = 0.1;
137137
while (step < steps) {
138-
auto extract = [](const mgis::span<double>& v) {
138+
auto extract = [](const std::span<double>& v) {
139139
return std::array<double, 4>{v[0], v[1], v[2], v[3]};
140140
};
141141
m.setTimeIncrement(dt);

bindings/fenics/tests/src/ElasticityUniaxialTensileTestImposedStress3D-sxx.cxx

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ int main() {
153153
mgis::size_type steps = 10;
154154
double dt = 0.1;
155155
while (step < steps) {
156-
auto extract = [](const mgis::span<double>& v) {
156+
auto extract = [](const std::span<double>& v) {
157157
return std::array<double, 6>{v[0], v[1], v[2], v[3], v[4], v[5]};
158158
};
159159
m.setTimeIncrement(dt);

bindings/fenics/tests/src/StandardElastoPlasticityPlasticityTest11-cyclic_E.cxx

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ int main() {
160160
mgis::size_type steps = 100;
161161
double dt = 0.01;
162162
while (step < steps) {
163-
auto extract = [](const mgis::span<double>& v) {
163+
auto extract = [](const std::span<double>& v) {
164164
return std::array<double, 6>{v[0], v[1], v[2], v[3], v[4], v[5]};
165165
};
166166
m.setTimeIncrement(dt);

bindings/python/include/MGIS/Python/NumPySupport.hxx

+8-8
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
#ifndef LIB_MGIS_PYTHON_NUMPYSUPPORT_HXX
1616
#define LIB_MGIS_PYTHON_NUMPYSUPPORT_HXX
1717

18+
#include <span>
1819
#include <vector>
1920
#include <variant>
2021
#include <boost/python/object.hpp>
2122
#include "MGIS/Config.hxx"
22-
#include "MGIS/Span.hxx"
2323

2424
namespace mgis::python {
2525

@@ -32,15 +32,15 @@ namespace mgis::python {
3232
* the vector.
3333
* \param[in] v: values
3434
*/
35-
boost::python::object wrapInNumPyArray(mgis::span<double>&);
35+
boost::python::object wrapInNumPyArray(std::span<double>&);
3636
/*!
3737
* \brief create a 1D-ndarray object from a vector.
3838
* The ndarray does not own the data, the lifetime of which is handled by
3939
* the vector.
4040
* \param[in] v: values
4141
*/
4242
boost::python::object wrapInNumPyArray(
43-
std::variant<mgis::span<double>, std::vector<double>>&);
43+
std::variant<std::span<double>, std::vector<double>>&);
4444
/*!
4545
* \brief create a 1D-ndarray object from a vector.
4646
* The ndarray does not own the data, the lifetime of which is handled by
@@ -55,7 +55,7 @@ namespace mgis::python {
5555
* \param[in] v: values
5656
* \param[in] nc: number of columns
5757
*/
58-
boost::python::object wrapInNumPyArray(mgis::span<double>&,
58+
boost::python::object wrapInNumPyArray(std::span<double>&,
5959
const mgis::size_type);
6060
/*!
6161
* \brief create a 2D-ndarray object from a vector.
@@ -65,7 +65,7 @@ namespace mgis::python {
6565
* \param[in] nc: number of columns
6666
*/
6767
boost::python::object wrapInNumPyArray(
68-
std::variant<mgis::span<double>, std::vector<double>>&,
68+
std::variant<std::span<double>, std::vector<double>>&,
6969
const mgis::size_type);
7070
/*!
7171
* \brief create a 2D-ndarray object from a vector.
@@ -84,7 +84,7 @@ namespace mgis::python {
8484
* \param[in] nl: number of line
8585
* \param[in] nc: number of columns
8686
*/
87-
boost::python::object wrapInNumPyArray(mgis::span<double>&,
87+
boost::python::object wrapInNumPyArray(std::span<double>&,
8888
const mgis::size_type,
8989
const mgis::size_type);
9090
/*!
@@ -96,7 +96,7 @@ namespace mgis::python {
9696
* \param[in] nc: number of columns
9797
*/
9898
boost::python::object wrapInNumPyArray(
99-
std::variant<mgis::span<double>, std::vector<double>>&,
99+
std::variant<std::span<double>, std::vector<double>>&,
100100
const mgis::size_type,
101101
const mgis::size_type);
102102
/*!
@@ -111,7 +111,7 @@ namespace mgis::python {
111111
const mgis::size_type,
112112
const mgis::size_type);
113113

114-
mgis::span<mgis::real> mgis_convert_to_span(const boost::python::object&);
114+
std::span<mgis::real> mgis_convert_to_span(const boost::python::object&);
115115

116116
} // end of namespace mgis::python
117117

0 commit comments

Comments
 (0)