Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NP_TMcode
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Giacomo Mulas
NP_TMcode
Commits
4392d34a
Commit
4392d34a
authored
1 year ago
by
Giovanni La Mura
Browse files
Options
Downloads
Patches
Plain Diff
Add public methods to read protected parameters and IOGVEC
parent
f8be5af3
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/include/Configuration.h
+38
-0
38 additions, 0 deletions
src/include/Configuration.h
src/libnptm/Configuration.cpp
+23
-2
23 additions, 2 deletions
src/libnptm/Configuration.cpp
with
61 additions
and
2 deletions
src/include/Configuration.h
+
38
−
0
View file @
4392d34a
...
...
@@ -361,6 +361,44 @@ public:
*/
static
ScattererConfiguration
*
from_dedfb
(
std
::
string
file_name
);
/*! \brief Get the ID of a sphere by its index.
*
* The proper way to access read-only parameters from outside a class is to define
* public methods that return their values. For arrays, particularly those that
* are accessed multiple times, it is convenient to have specialized methods that
* return the required values based on their index in the array.
*
* \param index: `int` Index of the ID to be retrieved.
* \return id: `int` The desired identifier.
*/
int
get_iog
(
int
index
)
{
return
iog_vec
[
index
];
}
/*! \brief Get the value of a parameter by name.
*
* The proper way to access read-only parameters from outside a class is to define
* public methods that return their values. For configuration operations, whose
* optimization is not critical, it is possible to define a single function that
* returns simple scalar values called by name. Access to more complicated data
* structures, on the other hand, require specialized methods which avoid the
* burden of searching the necessary value across the whole arrya every time.
*
* \param param_name: `string` Name of the parameter to be retrieved.
* \return value: `double` Value of the requested parameter.
*/
double
get_param
(
std
::
string
param_name
);
/*! \brief Get the value of a scale by its index.
*
* The proper way to access read-only parameters from outside a class is to define
* public methods that return their values. For arrays, particularly those that
* are accessed multiple times, it is convenient to have specialized methods that
* return the required values based on their index in the array.
*
* \param index: `int` Index of the scale to be retrieved.
* \return scale: `double` The desired scale.
*/
double
get_scale
(
int
index
)
{
return
scale_vec
[
index
];
}
/*! \brief Print the contents of the configuration object to terminal.
*
* In case of quick debug testing, `ScattererConfiguration.print()` allows printing
...
...
This diff is collapsed.
Click to expand it.
src/libnptm/Configuration.cpp
+
23
−
2
View file @
4392d34a
...
...
@@ -535,7 +535,7 @@ ScattererConfiguration* ScattererConfiguration::from_hdf5(string file_name) {
herr_t
status
=
hdf_file
->
get_status
();
string
str_name
,
str_type
;
if
(
status
==
0
)
{
int
nsph
;
int
nsph
,
ies
;
int
*
iog
;
double
_exdc
,
_wp
,
_xip
;
int
_idfc
,
nxi
;
...
...
@@ -545,6 +545,7 @@ ScattererConfiguration* ScattererConfiguration::from_hdf5(string file_name) {
double
**
rcf_vector
;
complex
<
double
>
***
dc0m
;
status
=
hdf_file
->
read
(
"NSPH"
,
"INT32_(1)"
,
&
nsph
);
status
=
hdf_file
->
read
(
"IES"
,
"INT32_(1)"
,
&
ies
);
status
=
hdf_file
->
read
(
"EXDC"
,
"FLOAT64_(1)"
,
&
_exdc
);
status
=
hdf_file
->
read
(
"WP"
,
"FLOAT64_(1)"
,
&
_wp
);
status
=
hdf_file
->
read
(
"XIP"
,
"FLOAT64_(1)"
,
&
_xip
);
...
...
@@ -613,7 +614,7 @@ ScattererConfiguration* ScattererConfiguration::from_hdf5(string file_name) {
rcf_vector
,
_idfc
,
dc0m
,
false
,
(
ies
==
1
)
,
_exdc
,
_wp
,
_xip
...
...
@@ -709,6 +710,23 @@ ScattererConfiguration* ScattererConfiguration::from_legacy(string file_name) {
return
conf
;
}
double
ScattererConfiguration
::
get_param
(
string
param_name
)
{
double
value
;
if
(
param_name
.
compare
(
"number_of_spheres"
)
==
0
)
value
=
1.0
*
number_of_spheres
;
else
if
(
param_name
.
compare
(
"nsph"
)
==
0
)
value
=
1.0
*
number_of_spheres
;
else
if
(
param_name
.
compare
(
"number_of_scales"
)
==
0
)
value
=
1.0
*
number_of_scales
;
else
if
(
param_name
.
compare
(
"nxi"
)
==
0
)
value
=
1.0
*
number_of_scales
;
else
if
(
param_name
.
compare
(
"idfc"
)
==
0
)
value
=
1.0
*
idfc
;
else
if
(
param_name
.
compare
(
"exdc"
)
==
0
)
value
=
exdc
;
else
if
(
param_name
.
compare
(
"wp"
)
==
0
)
value
=
wp
;
else
if
(
param_name
.
compare
(
"xip"
)
==
0
)
value
=
xip
;
else
{
// TODO: add exception code for unknown parameter.
return
0.0
;
}
return
value
;
}
void
ScattererConfiguration
::
print
()
{
int
ies
=
(
use_external_sphere
)
?
1
:
0
;
int
configurations
=
0
;
...
...
@@ -782,6 +800,9 @@ void ScattererConfiguration::write_hdf5(string file_name) {
rec_name_list
.
set
(
0
,
"NSPH"
);
rec_type_list
.
set
(
0
,
"INT32_(1)"
);
rec_ptr_list
.
set
(
0
,
&
number_of_spheres
);
rec_name_list
.
append
(
"IES"
);
rec_type_list
.
append
(
"INT32_(1)"
);
rec_ptr_list
.
append
(
&
ies
);
rec_name_list
.
append
(
"IOGVEC"
);
str_type
=
"INT32_("
+
to_string
(
number_of_spheres
)
+
")"
;
rec_type_list
.
append
(
str_type
);
...
...
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