Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
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
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
4810963e
Commit
4810963e
authored
8 years ago
by
Van Herck, Walter
Browse files
Options
Downloads
Patches
Plain Diff
Refactor: MatrixFresnelMap now maintains two caches (in/out) of calculated Fresnel coefficients
parent
166a89fc
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Core/Multilayer/MatrixFresnelMap.cpp
+28
-7
28 additions, 7 deletions
Core/Multilayer/MatrixFresnelMap.cpp
Core/Multilayer/MatrixFresnelMap.h
+9
-2
9 additions, 2 deletions
Core/Multilayer/MatrixFresnelMap.h
Core/Multilayer/ScalarFresnelMap.h
+1
-1
1 addition, 1 deletion
Core/Multilayer/ScalarFresnelMap.h
with
38 additions
and
10 deletions
Core/Multilayer/MatrixFresnelMap.cpp
+
28
−
7
View file @
4810963e
...
...
@@ -21,23 +21,44 @@
#include
"SpecularMagnetic.h"
MatrixFresnelMap
::
MatrixFresnelMap
(
const
MultiLayer
*
p_multilayer
,
const
MultiLayer
*
p_inverted_multilayer
)
const
MultiLayer
*
p_inverted_multilayer
)
:
mp_multilayer
(
p_multilayer
)
,
mp_inverted_multilayer
(
p_inverted_multilayer
)
{}
MatrixFresnelMap
::~
MatrixFresnelMap
()
{}
const
ILayerRTCoefficients
*
MatrixFresnelMap
::
getOutCoefficients
(
const
SimulationElement
&
sim_element
,
size_t
layer_index
)
const
{
std
::
vector
<
MatrixRTCoefficients
>
coeffs
;
SpecularMagnetic
::
execute
(
*
mp_inverted_multilayer
,
-
sim_element
.
getMeanKf
(),
coeffs
);
return
new
MatrixRTCoefficients
(
coeffs
[
layer_index
]);
MatrixRTCoefficients
*
result
;
kvector_t
kvec
=
-
sim_element
.
getMeanKf
();
auto
it
=
m_hash_table_out
.
find
(
kvec
);
if
(
it
!=
m_hash_table_out
.
end
())
result
=
new
MatrixRTCoefficients
(
it
->
second
[
layer_index
]);
else
{
std
::
vector
<
MatrixRTCoefficients
>
coeffs
;
SpecularMagnetic
::
execute
(
*
mp_inverted_multilayer
,
kvec
,
coeffs
);
result
=
new
MatrixRTCoefficients
(
coeffs
[
layer_index
]);
m_hash_table_out
[
kvec
]
=
std
::
move
(
coeffs
);
}
return
result
;
}
const
ILayerRTCoefficients
*
MatrixFresnelMap
::
getInCoefficients
(
const
SimulationElement
&
sim_element
,
size_t
layer_index
)
const
{
std
::
vector
<
MatrixRTCoefficients
>
coeffs
;
SpecularMagnetic
::
execute
(
*
mp_multilayer
,
sim_element
.
getKi
(),
coeffs
);
return
new
MatrixRTCoefficients
(
coeffs
[
layer_index
]);
MatrixRTCoefficients
*
result
;
kvector_t
kvec
=
sim_element
.
getKi
();
auto
it
=
m_hash_table_in
.
find
(
kvec
);
if
(
it
!=
m_hash_table_in
.
end
())
result
=
new
MatrixRTCoefficients
(
it
->
second
[
layer_index
]);
else
{
std
::
vector
<
MatrixRTCoefficients
>
coeffs
;
SpecularMagnetic
::
execute
(
*
mp_multilayer
,
kvec
,
coeffs
);
result
=
new
MatrixRTCoefficients
(
coeffs
[
layer_index
]);
m_hash_table_in
[
kvec
]
=
std
::
move
(
coeffs
);
}
return
result
;
}
This diff is collapsed.
Click to expand it.
Core/Multilayer/MatrixFresnelMap.h
+
9
−
2
View file @
4810963e
...
...
@@ -16,10 +16,13 @@
#ifndef MATRIXFRESNELMAP_H
#define MATRIXFRESNELMAP_H
#include
"HashKVector.h"
#include
"IFresnelMap.h"
#include
<cstddef>
#include
<unordered_map>
#include
<vector>
class
ILayerRTCoefficients
;
class
MatrixRTCoefficients
;
class
MultiLayer
;
class
SimulationElement
;
...
...
@@ -30,7 +33,7 @@ class BA_CORE_API_ MatrixFresnelMap : public IFresnelMap
{
public:
MatrixFresnelMap
(
const
MultiLayer
*
p_multilayer
,
const
MultiLayer
*
p_inverted_multilayer
);
~
MatrixFresnelMap
()
final
{}
~
MatrixFresnelMap
()
final
;
//! Retrieves the amplitude coefficients for the given angles
const
ILayerRTCoefficients
*
getOutCoefficients
(
...
...
@@ -43,6 +46,10 @@ public:
private:
const
MultiLayer
*
mp_multilayer
;
const
MultiLayer
*
mp_inverted_multilayer
;
mutable
std
::
unordered_map
<
kvector_t
,
std
::
vector
<
MatrixRTCoefficients
>
,
HashKVector
>
m_hash_table_out
;
mutable
std
::
unordered_map
<
kvector_t
,
std
::
vector
<
MatrixRTCoefficients
>
,
HashKVector
>
m_hash_table_in
;
};
#endif // MATRIXFRESNELMAP_H
This diff is collapsed.
Click to expand it.
Core/Multilayer/ScalarFresnelMap.h
+
1
−
1
View file @
4810963e
...
...
@@ -21,8 +21,8 @@
#include
<unordered_map>
#include
<vector>
class
MultiLayer
;
class
ILayerRTCoefficients
;
class
MultiLayer
;
class
ScalarRTCoefficients
;
class
SimulationElement
;
...
...
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