Skip to content
GitLab
Explore
Sign in
Giacomo Mulas
NP_TMcode
Compare revisions
bd60eab6b95523af89e899a099a7466ee3ebbd9d to f9e9f4b499925db0f54a8eab93054b2bbe52550a
Commits on Source (3)
Add an internal timer based on std::clock
· 483d1b36
Giovanni La Mura
authored
Apr 23, 2024
483d1b36
Pass string arguments by reference
· 88866a20
Giovanni La Mura
authored
Apr 24, 2024
88866a20
Build COMMON objects from configuration structures
· f9e9f4b4
Giovanni La Mura
authored
Apr 24, 2024
f9e9f4b4
Hide whitespace changes
Inline
Side-by-side
src/cluster/cluster.cpp
View file @
f9e9f4b4
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
*
*
* \brief Implementation of the calculation for a cluster of spheres.
* \brief Implementation of the calculation for a cluster of spheres.
*/
*/
#include
<chrono>
#include
<cstdio>
#include
<cstdio>
#include
<exception>
#include
<exception>
#include
<fstream>
#include
<fstream>
...
@@ -60,7 +61,11 @@ int cluster_jxi488_cycle(int jxi488, ScattererConfiguration *sconf, GeometryConf
...
@@ -60,7 +61,11 @@ int cluster_jxi488_cycle(int jxi488, ScattererConfiguration *sconf, GeometryConf
* \param data_file: `string` Name of the input data file.
* \param data_file: `string` Name of the input data file.
* \param output_path: `string` Directory to write the output files in.
* \param output_path: `string` Directory to write the output files in.
*/
*/
void
cluster
(
string
config_file
,
string
data_file
,
string
output_path
)
{
void
cluster
(
const
string
&
config_file
,
const
string
&
data_file
,
const
string
&
output_path
)
{
chrono
::
time_point
<
chrono
::
high_resolution_clock
>
t_start
=
chrono
::
high_resolution_clock
::
now
();
string
timing_name
=
output_path
+
"/c_timing.log"
;
FILE
*
timing_file
=
fopen
(
timing_name
.
c_str
(),
"w"
);
Logger
*
time_logger
=
new
Logger
(
LOG_DEBG
,
timing_file
);
Logger
*
logger
=
new
Logger
(
LOG_INFO
);
Logger
*
logger
=
new
Logger
(
LOG_INFO
);
logger
->
log
(
"INFO: making legacy configuration..."
,
LOG_INFO
);
logger
->
log
(
"INFO: making legacy configuration..."
,
LOG_INFO
);
ScattererConfiguration
*
sconf
=
NULL
;
ScattererConfiguration
*
sconf
=
NULL
;
...
@@ -119,7 +124,7 @@ void cluster(string config_file, string data_file, string output_path) {
...
@@ -119,7 +124,7 @@ void cluster(string config_file, string data_file, string output_path) {
if
(
le
>
lm
)
lm
=
le
;
if
(
le
>
lm
)
lm
=
le
;
C1
*
c1
=
new
C1
(
gconf
,
sconf
);
C1
*
c1
=
new
C1
(
gconf
,
sconf
);
C3
*
c3
=
new
C3
();
C3
*
c3
=
new
C3
();
C4
*
c4
=
new
C4
(
li
,
le
,
nsph
);
C4
*
c4
=
new
C4
(
gconf
);
C1_AddOns
*
c1ao
=
new
C1_AddOns
(
c4
);
C1_AddOns
*
c1ao
=
new
C1_AddOns
(
c4
);
// End of add-ons initialization
// End of add-ons initialization
C6
*
c6
=
new
C6
(
c4
->
lmtpo
);
C6
*
c6
=
new
C6
(
c4
->
lmtpo
);
...
@@ -129,9 +134,10 @@ void cluster(string config_file, string data_file, string output_path) {
...
@@ -129,9 +134,10 @@ void cluster(string config_file, string data_file, string output_path) {
dcomplex
arg
=
0.0
+
0.0
*
I
;
dcomplex
arg
=
0.0
+
0.0
*
I
;
dcomplex
ccsam
=
0.0
+
0.0
*
I
;
dcomplex
ccsam
=
0.0
+
0.0
*
I
;
int
configurations
=
(
int
)
sconf
->
get_param
(
"configurations"
);
int
configurations
=
(
int
)
sconf
->
get_param
(
"configurations"
);
C2
*
c2
=
new
C2
(
nsph
,
configurations
,
npnt
,
npntts
);
C2
*
c2
=
new
C2
(
gconf
,
sconf
);
np_int
ndit
=
2
*
nsph
*
c4
->
nlim
;
np_int
ndit
=
2
*
nsph
*
c4
->
nlim
;
logger
->
log
(
"INFO: Size of matrices to invert: "
+
to_string
((
int64_t
)
ndit
)
+
" x "
+
to_string
((
int64_t
)
ndit
)
+
".
\n
"
);
logger
->
log
(
"INFO: Size of matrices to invert: "
+
to_string
((
int64_t
)
ndit
)
+
" x "
+
to_string
((
int64_t
)
ndit
)
+
".
\n
"
);
time_logger
->
log
(
"INFO: Size of matrices to invert: "
+
to_string
((
int64_t
)
ndit
)
+
" x "
+
to_string
((
int64_t
)
ndit
)
+
".
\n
"
);
const
int
ndi
=
c4
->
nsph
*
c4
->
nlim
;
const
int
ndi
=
c4
->
nsph
*
c4
->
nlim
;
C9
*
c9
=
new
C9
(
ndi
,
c4
->
nlem
,
2
*
ndi
,
2
*
c4
->
nlem
);
C9
*
c9
=
new
C9
(
ndi
,
c4
->
nlem
,
2
*
ndi
,
2
*
c4
->
nlem
);
double
*
gaps
=
new
double
[
nsph
]();
double
*
gaps
=
new
double
[
nsph
]();
...
@@ -795,7 +801,14 @@ void cluster(string config_file, string data_file, string output_path) {
...
@@ -795,7 +801,14 @@ void cluster(string config_file, string data_file, string output_path) {
}
}
delete
sconf
;
delete
sconf
;
delete
gconf
;
delete
gconf
;
chrono
::
time_point
<
chrono
::
high_resolution_clock
>
t_end
=
chrono
::
high_resolution_clock
::
now
();
const
chrono
::
duration
<
double
>
elapsed
=
t_end
-
t_start
;
string
message
=
"Calculation lasted "
+
to_string
(
elapsed
.
count
())
+
".
\n
"
;
logger
->
log
(
message
);
logger
->
log
(
"Finished: output written to "
+
output_path
+
"/c_OCLU
\n
"
);
logger
->
log
(
"Finished: output written to "
+
output_path
+
"/c_OCLU
\n
"
);
time_logger
->
log
(
message
);
fclose
(
timing_file
);
delete
time_logger
;
delete
logger
;
delete
logger
;
}
}
...
...
src/cluster/np_cluster.cpp
View file @
f9e9f4b4
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
using
namespace
std
;
using
namespace
std
;
extern
void
cluster
(
string
config_file
,
string
data_file
,
string
output_path
);
extern
void
cluster
(
const
string
&
config_file
,
const
string
&
data_file
,
const
string
&
output_path
);
/*! \brief Main program entry point.
/*! \brief Main program entry point.
*
*
...
...
src/include/Commons.h
View file @
f9e9f4b4
...
@@ -140,12 +140,10 @@ public:
...
@@ -140,12 +140,10 @@ public:
/*! \brief C2 instance constructor.
/*! \brief C2 instance constructor.
*
*
* \param ns: `int` Number of spheres.
* \param gconf: `GeometryConfiguration*` Pointer to a GeometryConfiguration instance.
* \param nl: `int`
* \param sconf: `ScattererConfiguration*` Pointer to a ScattererConfiguration instance.
* \param npnt: `int`
* \param npntts: `int`
*/
*/
C2
(
int
ns
,
int
nl
,
int
npnt
,
int
npntts
);
C2
(
GeometryConfiguration
*
gconf
,
ScattererConfiguration
*
sconf
);
/*! \brief C2 instance constructor copying its contents from preexisting instance.
/*! \brief C2 instance constructor copying its contents from preexisting instance.
*
*
...
@@ -216,14 +214,19 @@ public:
...
@@ -216,14 +214,19 @@ public:
//! \brief QUESTION: definition?
//! \brief QUESTION: definition?
int
nv3j
;
int
nv3j
;
/*! \brief C3 instance constructor.
/*! \brief C4 instance constructor.
*
* \param gconf: `GeometryConfiguration*` Pointer to a GeometryConfiguration instance.
*/
*/
C4
(
int
li
,
int
le
,
int
nsph
);
C4
(
GeometryConfiguration
*
gconf
);
/*! \brief C3 instance constructor copying its contents from a preexisting object.
/*! \brief C4 instance constructor copying its contents from a preexisting object.
*
* \param rhs: `C4&` Reference of the object to be copied.
*/
*/
C4
(
const
C4
&
rhs
);
C4
(
const
C4
&
rhs
);
/*! \brief C
3
instance destroyer.
/*! \brief C
4
instance destroyer.
*/
*/
~
C4
();
~
C4
();
};
};
...
...
src/libnptm/Commons.cpp
View file @
f9e9f4b4
...
@@ -366,11 +366,14 @@ C1_AddOns::~C1_AddOns() {
...
@@ -366,11 +366,14 @@ C1_AddOns::~C1_AddOns() {
delete
[]
ecsc
;
delete
[]
ecsc
;
}
}
C2
::
C2
(
int
ns
,
int
_nl
,
int
npnt
,
int
npntts
)
{
C2
::
C2
(
GeometryConfiguration
*
gconf
,
ScattererConfiguration
*
sconf
)
{
nsph
=
ns
;
nsph
=
(
int
)
gconf
->
get_param
(
"nsph"
);
int
npnt
=
(
int
)
gconf
->
get_param
(
"npnt"
);
int
npntts
=
(
int
)
gconf
->
get_param
(
"npntts"
);
int
max_n
=
(
npnt
>
npntts
)
?
npnt
:
npntts
;
int
max_n
=
(
npnt
>
npntts
)
?
npnt
:
npntts
;
nhspo
=
2
*
max_n
-
1
;
nhspo
=
2
*
max_n
-
1
;
nl
=
_nl
;
nl
=
(
int
)
sconf
->
get_param
(
"configurations"
);
if
(
nsph
==
1
&&
nl
==
1
)
nl
=
5
;
ris
=
new
dcomplex
[
nhspo
]();
ris
=
new
dcomplex
[
nhspo
]();
dlri
=
new
dcomplex
[
nhspo
]();
dlri
=
new
dcomplex
[
nhspo
]();
vkt
=
new
dcomplex
[
nsph
]();
vkt
=
new
dcomplex
[
nsph
]();
...
@@ -436,20 +439,20 @@ C3::~C3() {
...
@@ -436,20 +439,20 @@ C3::~C3() {
delete
[]
tsas
;
delete
[]
tsas
;
}
}
C4
::
C4
(
int
_li
,
int
_le
,
int
_nsph
)
{
C4
::
C4
(
GeometryConfiguration
*
gconf
)
{
li
=
_li
;
li
=
(
int
)
gconf
->
get_param
(
"li"
)
;
le
=
_le
;
le
=
(
int
)
gconf
->
get_param
(
"le"
)
;
lm
=
(
li
>
le
)
?
li
:
le
;
lm
=
(
li
>
le
)
?
li
:
le
;
nv3j
=
(
lm
*
(
lm
+
1
)
*
(
2
*
lm
+
7
))
/
6
;
nv3j
=
(
lm
*
(
lm
+
1
)
*
(
2
*
lm
+
7
))
/
6
;
nsph
=
_
nsph
;
nsph
=
(
int
)
gconf
->
get_param
(
"
nsph
"
)
;
// The following is needed to initialize C1_AddOns
// The following is needed to initialize C1_AddOns
litpo
=
li
+
li
+
1
;
litpo
=
li
+
li
+
1
;
litpos
=
litpo
*
litpo
;
litpos
=
litpo
*
litpo
;
lmtpo
=
li
+
le
+
1
;
lmtpo
=
li
+
le
+
1
;
lmtpos
=
lmtpo
*
lmtpo
;
lmtpos
=
lmtpo
*
lmtpo
;
nlim
=
li
*
(
li
+
2
);
nlim
=
li
*
(
li
+
2
);
nlem
=
le
*
(
le
+
2
);
nlem
=
le
*
(
le
+
2
);
lmpo
=
lm
+
1
;
lmpo
=
lm
+
1
;
}
}
C4
::
C4
(
const
C4
&
rhs
)
{
C4
::
C4
(
const
C4
&
rhs
)
{
...
...
src/sphere/np_sphere.cpp
View file @
f9e9f4b4
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
using
namespace
std
;
using
namespace
std
;
extern
void
sphere
(
string
config_file
,
string
data_file
,
string
output_path
);
extern
void
sphere
(
const
string
&
config_file
,
const
string
&
data_file
,
const
string
&
output_path
);
/*! \brief Main program entry point.
/*! \brief Main program entry point.
*
*
...
...
src/sphere/sphere.cpp
View file @
f9e9f4b4
...
@@ -45,7 +45,7 @@ using namespace std;
...
@@ -45,7 +45,7 @@ using namespace std;
* \param data_file: `string` Name of the input data file.
* \param data_file: `string` Name of the input data file.
* \param output_path: `string` Directory to write the output files in.
* \param output_path: `string` Directory to write the output files in.
*/
*/
void
sphere
(
string
config_file
,
string
data_file
,
string
output_path
)
{
void
sphere
(
const
string
&
config_file
,
const
string
&
data_file
,
const
string
&
output_path
)
{
Logger
*
logger
=
new
Logger
(
LOG_INFO
);
Logger
*
logger
=
new
Logger
(
LOG_INFO
);
dcomplex
arg
,
s0
,
tfsas
;
dcomplex
arg
,
s0
,
tfsas
;
double
th
,
ph
;
double
th
,
ph
;
...
@@ -133,7 +133,7 @@ void sphere(string config_file, string data_file, string output_path) {
...
@@ -133,7 +133,7 @@ void sphere(string config_file, string data_file, string output_path) {
double
sc_phi_start
=
gconf
->
get_param
(
"sc_phi_start"
);
double
sc_phi_start
=
gconf
->
get_param
(
"sc_phi_start"
);
double
sc_phi_step
=
gconf
->
get_param
(
"sc_phi_step"
);
double
sc_phi_step
=
gconf
->
get_param
(
"sc_phi_step"
);
double
sc_phi_end
=
gconf
->
get_param
(
"sc_phi_end"
);
double
sc_phi_end
=
gconf
->
get_param
(
"sc_phi_end"
);
C2
*
c2
=
new
C2
(
nsph
,
5
,
npnt
,
npntts
);
C2
*
c2
=
new
C2
(
gconf
,
sconf
);
argi
=
new
double
[
1
];
argi
=
new
double
[
1
];
args
=
new
double
[
1
];
args
=
new
double
[
1
];
gaps
=
new
double
[
2
];
gaps
=
new
double
[
2
];
...
...