Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Özgür Ozan Sen
ogs
Commits
284e4a11
Commit
284e4a11
authored
2 years ago
by
Christoph Lehmann
Browse files
Options
Downloads
Patches
Plain Diff
[PL] Hardened getters and setters with additional checks
parent
12dd20bd
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ProcessLib/Utils/SetOrGetIntegrationPointData.h
+32
-6
32 additions, 6 deletions
ProcessLib/Utils/SetOrGetIntegrationPointData.h
with
32 additions
and
6 deletions
ProcessLib/Utils/SetOrGetIntegrationPointData.h
+
32
−
6
View file @
284e4a11
...
...
@@ -28,7 +28,9 @@ std::vector<double> const& getIntegrationPointKelvinVectorData(
{
return
getIntegrationPointKelvinVectorData
<
DisplacementDim
>
(
ip_data_vector
,
[
member
](
IpData
const
&
ip_data
)
{
return
ip_data
.
*
member
;
},
[
member
](
IpData
const
&
ip_data
)
->
auto
const
&
{
return
ip_data
.
*
member
;
},
cache
);
}
...
...
@@ -38,6 +40,12 @@ std::vector<double> const& getIntegrationPointKelvinVectorData(
IntegrationPointDataVector
const
&
ip_data_vector
,
Accessor
&&
accessor
,
std
::
vector
<
double
>&
cache
)
{
using
AccessorResult
=
decltype
(
std
::
declval
<
Accessor
>
()(
std
::
declval
<
IntegrationPointDataVector
>
()[
0
]));
static_assert
(
std
::
is_lvalue_reference_v
<
AccessorResult
>
,
"The ip data accessor should return a reference. This check "
"prevents accidental copies."
);
constexpr
int
kelvin_vector_size
=
MathLib
::
KelvinVector
::
kelvin_vector_dimensions
(
DisplacementDim
);
auto
const
n_integration_points
=
ip_data_vector
.
size
();
...
...
@@ -90,6 +98,11 @@ std::size_t setIntegrationPointKelvinVectorData(
IntegrationPointDataVector
&
ip_data_vector
,
Accessor
&&
accessor
)
{
using
AccessorResult
=
decltype
(
std
::
declval
<
Accessor
>
()(
std
::
declval
<
IntegrationPointDataVector
>
()[
0
]));
static_assert
(
std
::
is_lvalue_reference_v
<
AccessorResult
>
,
"The ip data accessor must return a reference."
);
constexpr
int
kelvin_vector_size
=
MathLib
::
KelvinVector
::
kelvin_vector_dimensions
(
DisplacementDim
);
auto
const
n_integration_points
=
ip_data_vector
.
size
();
...
...
@@ -117,7 +130,9 @@ std::vector<double> const& getIntegrationPointScalarData(
{
return
getIntegrationPointScalarData
(
ip_data_vector
,
[
member
](
IpData
const
&
ip_data
)
{
return
ip_data
.
*
member
;
},
[
member
](
IpData
const
&
ip_data
)
->
auto
const
&
{
return
ip_data
.
*
member
;
},
cache
);
}
...
...
@@ -126,6 +141,12 @@ std::vector<double> const& getIntegrationPointScalarData(
IntegrationPointDataVector
const
&
ip_data_vector
,
Accessor
&&
accessor
,
std
::
vector
<
double
>&
cache
)
{
using
AccessorResult
=
decltype
(
std
::
declval
<
Accessor
>
()(
std
::
declval
<
IntegrationPointDataVector
>
()[
0
]));
static_assert
(
std
::
is_lvalue_reference_v
<
AccessorResult
>
,
"The ip data accessor should return a reference. This check "
"prevents accidental copies."
);
auto
const
n_integration_points
=
ip_data_vector
.
size
();
cache
.
clear
();
...
...
@@ -148,10 +169,10 @@ std::size_t setIntegrationPointScalarData(
IntegrationPointDataVector
&
ip_data_vector
,
MemberType
IpData
::*
const
member
)
{
return
setIntegrationPointScalarData
(
values
,
ip_data_vector
,
[
member
](
IpData
const
&
ip_data
)
{
return
ip_data
.
*
member
;
});
return
setIntegrationPointScalarData
(
values
,
ip_data_vector
,
[
member
](
IpData
&
ip_data
)
->
auto
&
{
return
ip_data
.
*
member
;
});
}
template
<
typename
IntegrationPointDataVector
,
typename
Accessor
>
...
...
@@ -160,6 +181,11 @@ std::size_t setIntegrationPointScalarData(
IntegrationPointDataVector
&
ip_data_vector
,
Accessor
&&
accessor
)
{
using
AccessorResult
=
decltype
(
std
::
declval
<
Accessor
>
()(
std
::
declval
<
IntegrationPointDataVector
>
()[
0
]));
static_assert
(
std
::
is_lvalue_reference_v
<
AccessorResult
>
,
"The ip data accessor must return a reference."
);
auto
const
n_integration_points
=
ip_data_vector
.
size
();
for
(
unsigned
ip
=
0
;
ip
<
n_integration_points
;
++
ip
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment