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
Chaofan Chen
ogs
Commits
af2ce73e
Commit
af2ce73e
authored
1 year ago
by
Christoph Lehmann
Browse files
Options
Downloads
Patches
Plain Diff
[MPL] Made function property thread safe
parent
5382e6ce
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
MaterialLib/MPL/Properties/Function.cpp
+13
-7
13 additions, 7 deletions
MaterialLib/MPL/Properties/Function.cpp
MaterialLib/MPL/Properties/Function.h
+2
-0
2 additions, 0 deletions
MaterialLib/MPL/Properties/Function.h
with
15 additions
and
7 deletions
MaterialLib/MPL/Properties/Function.cpp
+
13
−
7
View file @
af2ce73e
...
@@ -77,13 +77,18 @@ static void updateVariableValues(
...
@@ -77,13 +77,18 @@ static void updateVariableValues(
static
PropertyDataType
evaluateExpressions
(
static
PropertyDataType
evaluateExpressions
(
std
::
vector
<
std
::
pair
<
Variable
,
double
*>>
const
&
symbol_values
,
std
::
vector
<
std
::
pair
<
Variable
,
double
*>>
const
&
symbol_values
,
VariableArray
const
&
variable_array
,
VariableArray
const
&
variable_array
,
std
::
vector
<
exprtk
::
expression
<
double
>>
const
&
expressions
)
std
::
vector
<
exprtk
::
expression
<
double
>>
const
&
expressions
,
std
::
mutex
&
mutex
)
{
{
updateVariableValues
(
symbol_values
,
variable_array
);
std
::
vector
<
double
>
result
(
expressions
.
size
());
std
::
vector
<
double
>
result
(
expressions
.
size
());
std
::
transform
(
begin
(
expressions
),
end
(
expressions
),
begin
(
result
),
[](
auto
const
&
e
)
{
return
e
.
value
();
});
{
std
::
lock_guard
lock_guard
(
mutex
);
updateVariableValues
(
symbol_values
,
variable_array
);
std
::
transform
(
begin
(
expressions
),
end
(
expressions
),
begin
(
result
),
[](
auto
const
&
e
)
{
return
e
.
value
();
});
}
switch
(
result
.
size
())
switch
(
result
.
size
())
{
{
...
@@ -187,7 +192,7 @@ PropertyDataType Function::value(VariableArray const& variable_array,
...
@@ -187,7 +192,7 @@ PropertyDataType Function::value(VariableArray const& variable_array,
double
const
/*t*/
,
double
const
/*dt*/
)
const
double
const
/*t*/
,
double
const
/*dt*/
)
const
{
{
return
evaluateExpressions
(
symbol_values_
,
variable_array
,
return
evaluateExpressions
(
symbol_values_
,
variable_array
,
value_expressions_
);
value_expressions_
,
mutex_
);
}
}
PropertyDataType
Function
::
dValue
(
VariableArray
const
&
variable_array
,
PropertyDataType
Function
::
dValue
(
VariableArray
const
&
variable_array
,
...
@@ -208,7 +213,8 @@ PropertyDataType Function::dValue(VariableArray const& variable_array,
...
@@ -208,7 +213,8 @@ PropertyDataType Function::dValue(VariableArray const& variable_array,
variable_enum_to_string
[
static_cast
<
int
>
(
variable
)],
name_
);
variable_enum_to_string
[
static_cast
<
int
>
(
variable
)],
name_
);
}
}
return
evaluateExpressions
(
symbol_values_
,
variable_array
,
it
->
second
);
return
evaluateExpressions
(
symbol_values_
,
variable_array
,
it
->
second
,
mutex_
);
}
}
}
// namespace MaterialPropertyLib
}
// namespace MaterialPropertyLib
This diff is collapsed.
Click to expand it.
MaterialLib/MPL/Properties/Function.h
+
2
−
0
View file @
af2ce73e
...
@@ -55,5 +55,7 @@ private:
...
@@ -55,5 +55,7 @@ private:
/// Multiple expressions are representing vector-valued functions.
/// Multiple expressions are representing vector-valued functions.
std
::
vector
<
std
::
pair
<
Variable
,
std
::
vector
<
Expression
>>>
std
::
vector
<
std
::
pair
<
Variable
,
std
::
vector
<
Expression
>>>
dvalue_expressions_
;
dvalue_expressions_
;
mutable
std
::
mutex
mutex_
;
};
};
}
// namespace MaterialPropertyLib
}
// namespace MaterialPropertyLib
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