Skip to content

Commit 84f6b06

Browse files
authored
Merge pull request #198 from thelfer/196-mgisfunction-add-function-view-with-strided-coalesent-memory-access
Fix Issues #196 and #197
2 parents f6c83f8 + 0b1deaf commit 84f6b06

21 files changed

Lines changed: 1239 additions & 53 deletions

bindings/python/src/State.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ static pybind11::object State_getExternalStateVariables(
4343
} // end of State_getExternalStateVariables
4444

4545
static void State_setMaterialProperty(mgis::behaviour::State& s,
46-
const std::string& n,
47-
const mgis::real v) {
46+
const std::string& n,
47+
const mgis::real v) {
4848
mgis::behaviour::setMaterialProperty(s, n, v);
4949
} // end of State_setMaterialProperty
5050

docs/web/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ if(MGIS_HAVE_PANDOC)
8686
mgis_pandoc_generate_html_page(release-notes-3.0.2 "--toc" "--toc-depth=3")
8787
mgis_pandoc_generate_html_page(release-notes-3.0.3 "--toc" "--toc-depth=3")
8888
mgis_pandoc_generate_html_page(release-notes-3.1 "--toc" "--toc-depth=3")
89+
mgis_pandoc_generate_html_page(release-notes-3.1.1 "--toc" "--toc-depth=3")
90+
mgis_pandoc_generate_html_page(release-notes-3.2 "--toc" "--toc-depth=3")
8991
mgis_pandoc_generate_html_page(orthotropic-behaviours "--toc" "--toc-depth=3")
9092
mgis_pandoc_generate_html_page(behaviour-integration-failure-analysis "--toc" "--toc-depth=3")
9193
mgis_pandoc_generate_html_page(functions "--toc" "--toc-depth=3")

docs/web/mgis-template.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@
127127
<li><a>Version 3.1.x</a>
128128
<ul>
129129
<li><a href="release-notes-3.1.html">Version 3.1</a></li>
130+
<li><a href="release-notes-3.1.1.html">Version 3.1.1</a></li>
131+
</ul>
132+
<li><a>Version 3.2.x</a>
133+
<ul>
134+
<li><a href="release-notes-3.2.html">Version 3.2</a></li>
130135
</ul>
131136
</li>
132137
</ul>

docs/web/release-notes-3.1.1.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
title: MFrontGenericInterfaceSupport Version 3.1.1
3+
author: Thomas Helfer
4+
date: 2026
5+
lang: en-EN
6+
numbersections: true
7+
documentclass: article
8+
from: markdown+tex_math_single_backslash
9+
geometry:
10+
- margin=2cm
11+
papersize: a4
12+
link-citations: true
13+
colorlinks: true
14+
figPrefixTemplate: "$$i$$"
15+
tabPrefixTemplate: "$$i$$"
16+
secPrefixTemplate: "$$i$$"
17+
eqnPrefixTemplate: "($$i$$)"
18+
bibliography: bibliography.bib
19+
---
20+
21+
The page describes the new functionalities of Version 3.1.1 of the
22+
`MFrontGenericInterfaceSupport` project.
23+
24+
# Issues fixed
25+
26+
## Issue 197: [MGIS/Function] Fix `CoalescedMemoryAccessCompositeTensorsView` for scalar values
27+
28+
For more details, see <https://github.com/thelfer/MFrontGenericInterfaceSupport/issues/197>

docs/web/release-notes-3.2.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---
2+
title: MFrontGenericInterfaceSupport Version 3.2
3+
author: Thomas Helfer
4+
date: 2026
5+
lang: en-EN
6+
numbersections: true
7+
documentclass: article
8+
from: markdown+tex_math_single_backslash
9+
geometry:
10+
- margin=2cm
11+
papersize: a4
12+
link-citations: true
13+
colorlinks: true
14+
figPrefixTemplate: "$$i$$"
15+
tabPrefixTemplate: "$$i$$"
16+
secPrefixTemplate: "$$i$$"
17+
eqnPrefixTemplate: "($$i$$)"
18+
bibliography: bibliography.bib
19+
---
20+
21+
This version is meant to be used with `TFEL` Version 5.2.
22+
23+
# New features of the `MGIS/Function` library
24+
25+
## Functions using a strided memory access
26+
27+
The following classes have been introduced:
28+
29+
- `StridedCoalescedMemoryAccessTensorView`
30+
- `StridedCoalescedMemoryAccessCompositeTensorsView`
31+
32+
### `StridedCoalescedMemoryAccessTensorView`
33+
34+
`StridedCoalescedMemoryAccessTensorView` is a tensorial function view
35+
which stores its components in non interleaved manner using the
36+
following scheme:
37+
38+
~~~~
39+
| <------- Component 1 ---------> |....| <----- Component Nc ---------> |
40+
+-------++-------++------++-------+----+-------++------++------++-------+
41+
| Elt 1 || Elt 2 || .... || Elt N |....| Elt 1 ||Elt 2 || .... || Elt N |
42+
+-------++-------++------++-------+----+-------++------++------++-------+
43+
~~~~
44+
45+
#### Example of usage
46+
47+
~~~~{.cxx}
48+
constexpr auto ne = size_type{2};
49+
auto space = BasicLinearSpace{ne};
50+
std::array<const real, 4 * ne> values = {1, 10, 2, 20, 3, 30, 4, 40};
51+
const auto f = StridedCoalescedMemoryAccessTensorView<
52+
BasicLinearSpace, tfel::math::stensor<2, real>, false>{space, values};
53+
const auto e1 = f(0);
54+
// e1 = {1, 2, 3, 4}
55+
const auto e2 = f(1);
56+
// e2 = {10, 20, 30, 40}
57+
~~~~
58+
59+
## `StridedCoalescedMemoryAccessCompositeTensorsView`
60+
61+
`StridedCoalescedMemoryAccessCompositeTensorsView` allows retrieving
62+
scalar or tensorial objects which are stored in a non interleaved
63+
manner.
64+
65+
#### Example of usage
66+
67+
~~~~{.cxx}
68+
using CompositeFunctionView =
69+
StridedCoalescedMemoryAccessCompositeTensorsView<BasicLinearSpace, 4,
70+
false>;
71+
constexpr auto ne = size_type{2};
72+
auto space = BasicLinearSpace{ne};
73+
std::array<const real, 4 * ne> values = {1, 10, 2, 20, 3, 30, 4, 40};
74+
const auto f = CompositeFunctionView{space, values};
75+
const auto e1 = f.get<0, tfel::math::stensor<2, real>>(0);
76+
// e1 = {1, 2, 3, 4}
77+
const auto e2 = f.get<0, tfel::math::stensor<2, real>>(1);
78+
// e2 = {10, 20, 30, 40}
79+
~~~~
80+
81+
# Acknowledgements
82+
83+
The authors are grateful to the many contributors to the `TFEL/MFront`
84+
project. This research was conducted in the framework of the PLEIADES
85+
project, which was supported financially by the CEA (Commissariat à
86+
l’Énergie Atomique et aux Énergies Alternatives), EDF (Électricité de
87+
France) and Framatome. Work on `MGIS/Function` was performed as part of
88+
the EURATOM OperaHPC Project co-funded by the European Union.
89+
90+
# Issues fixed

include/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,10 @@ if(enable-mgis-function)
9797
mgis_header(MGIS/Function/Tensors CoalescedMemoryAccessTensorView.ixx)
9898
mgis_header(MGIS/Function/Tensors CoalescedMemoryAccessCompositeTensorsView.hxx)
9999
mgis_header(MGIS/Function/Tensors CoalescedMemoryAccessCompositeTensorsView.ixx)
100+
mgis_header(MGIS/Function StridedCoalescedMemoryAccessFunctionViewBase.hxx)
101+
mgis_header(MGIS/Function StridedCoalescedMemoryAccessFunctionViewBase.ixx)
102+
mgis_header(MGIS/Function/Tensors StridedCoalescedMemoryAccessTensorView.hxx)
103+
mgis_header(MGIS/Function/Tensors StridedCoalescedMemoryAccessTensorView.ixx)
104+
mgis_header(MGIS/Function/Tensors StridedCoalescedMemoryAccessCompositeTensorsView.hxx)
105+
mgis_header(MGIS/Function/Tensors StridedCoalescedMemoryAccessCompositeTensorsView.ixx)
100106
endif(enable-mgis-function)
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
/*!
2+
* \file MGIS/Function/StridedCoalescedMemoryAccessFunctionViewBase.hxx
3+
* \brief
4+
* \author Thomas Helfer
5+
* \date 17/01/2026
6+
* \copyright (C) Copyright Thomas Helfer 2018.
7+
* Use, modification and distribution are subject
8+
* to one of the following licences:
9+
* - GNU Lesser General Public License (LGPL), Version 3.0. (See accompanying
10+
* file LGPL-3.0.txt)
11+
* - CECILL-C, Version 1.0 (See accompanying files
12+
* CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt).
13+
*/
14+
15+
#ifndef LIB_MGIS_FUNCTION_STRIDEDCOALESCEDMEMORYACCESSFUNCTIONVIEWBASE_HXX
16+
#define LIB_MGIS_FUNCTION_STRIDEDCOALESCEDMEMORYACCESSFUNCTIONVIEWBASE_HXX
17+
18+
#include <span>
19+
#include <array>
20+
#include "MGIS/Config.hxx"
21+
#include "MGIS/Contract.hxx"
22+
#include "MGIS/Function/SpaceConcept.hxx"
23+
#include "MGIS/Function/FunctionConcept.hxx"
24+
#include "MGIS/Function/Function.hxx"
25+
#include "MGIS/Function/Evaluator.hxx"
26+
27+
namespace mgis::function {
28+
29+
/*!
30+
* \brief a class meant to describe a function, each component of which is
31+
* stored contiguously in non interleaved manner using the following scheme:
32+
*
33+
* ~~~~
34+
* | <------- Component 1 ---------> |....| <----- Component Nc ---------> |
35+
* +-------++-------++------++-------+----+-------++------++------++-------+
36+
* | Elt 1 || Elt 2 || .... || Elt N |....| Elt 1 ||Elt 2 || .... || Elt N |
37+
* +-------++-------++------++-------+----+-------++------++------++-------+
38+
* ~~~~
39+
*/
40+
template <FunctionalSpaceConcept Space, size_type N, bool is_mutable = true>
41+
requires(N > 0) struct StridedCoalescedMemoryAccessFunctionViewBase
42+
: private PreconditionsChecker<
43+
StridedCoalescedMemoryAccessFunctionViewBase<Space,
44+
N,
45+
is_mutable>> {
46+
/*!
47+
* \brief check that the preconditions to build the view are met
48+
* \param[in] eh: error handler.
49+
* \param[in] space: space
50+
* \param[in] values: values
51+
*/
52+
[[nodiscard]] static constexpr bool checkPreconditions(
53+
AbstractErrorHandler&,
54+
const Space& space,
55+
std::span<const real>) requires(!is_mutable);
56+
/*!
57+
* \param[in] space: space
58+
* \param[in] values: values
59+
*/
60+
constexpr StridedCoalescedMemoryAccessFunctionViewBase(
61+
const Space&, std::span<const real>) requires(!is_mutable);
62+
/*!
63+
* \brief check that the preconditions to build the view are met
64+
* \param[in] eh: error handler.
65+
* \param[in] space: space
66+
* \param[in] values: values
67+
*/
68+
[[nodiscard]] static constexpr bool checkPreconditions(
69+
AbstractErrorHandler&, const Space&, std::span<real>);
70+
/*!
71+
* \param[in] space: space
72+
* \param[in] values: values
73+
*/
74+
constexpr StridedCoalescedMemoryAccessFunctionViewBase(const Space&,
75+
std::span<real>);
76+
/*!
77+
* \return the data associated with an integration point
78+
* \param[in] o: offset associated with the integration point
79+
*/
80+
[[nodiscard]] constexpr std::array<real, N> getValues(const size_type) const
81+
requires(LinearElementSpaceConcept<Space>);
82+
/*!
83+
* \return the data associated with an integration point
84+
* \param[in] e: element index
85+
* \param[in] i: quadrature point index
86+
*/
87+
[[nodiscard]] constexpr std::array<real, N> getValues(const size_type,
88+
const size_type) const
89+
requires(LinearQuadratureSpaceConcept<Space>);
90+
//! \return the underlying quadrature space
91+
[[nodiscard]] constexpr const Space& getSpace() const noexcept;
92+
93+
protected:
94+
/*!
95+
* \param[in] space: space
96+
* \param[in] values: values
97+
*/
98+
template <bool doPreconditionsCheck>
99+
constexpr StridedCoalescedMemoryAccessFunctionViewBase(
100+
const PreconditionsCheck<doPreconditionsCheck>&,
101+
const Space&,
102+
std::span<const real>) requires(!is_mutable);
103+
/*!
104+
* \param[in] space: space
105+
* \param[in] values: values
106+
*/
107+
template <bool doPreconditionsCheck>
108+
constexpr StridedCoalescedMemoryAccessFunctionViewBase(
109+
const PreconditionsCheck<doPreconditionsCheck>&,
110+
const Space&,
111+
std::span<real>);
112+
//! \brief underlying discretization space
113+
const Space space;
114+
//! \brief pointer to the first component
115+
const std::conditional_t<is_mutable, real*, const real*> data_pointer;
116+
};
117+
118+
} // namespace mgis::function
119+
120+
#include "MGIS/Function/StridedCoalescedMemoryAccessFunctionViewBase.ixx"
121+
122+
#endif /* LIB_MGIS_FUNCTION_STRIDEDCOALESCEDMEMORYACCESSFUNCTIONVIEWBASE_HXX \
123+
*/

0 commit comments

Comments
 (0)