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
92c1d8b2
Commit
92c1d8b2
authored
1 year ago
by
Giovanni La Mura
Browse files
Options
Downloads
Patches
Plain Diff
Implement dynamic memory management for spherical harmonics
parent
9c447a2d
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/sph_subs.h
+7
-3
7 additions, 3 deletions
src/include/sph_subs.h
src/sphere/sphere.cpp
+15
-16
15 additions, 16 deletions
src/sphere/sphere.cpp
with
22 additions
and
19 deletions
src/include/sph_subs.h
+
7
−
3
View file @
92c1d8b2
...
...
@@ -954,7 +954,9 @@ void sphar(
double
cosrth
,
double
sinrth
,
double
cosrph
,
double
sinrph
,
int
ll
,
std
::
complex
<
double
>
*
ylm
)
{
double
sinrmp
[
40
],
cosrmp
[
40
],
plegn
[
861
];
int
rmp_size
=
ll
;
int
plegn_size
=
(
ll
+
1
)
*
ll
/
2
+
ll
+
1
;
double
sinrmp
[
rmp_size
],
cosrmp
[
rmp_size
],
plegn
[
plegn_size
];
double
four_pi
=
8.0
*
acos
(
0.0
);
double
pi4irs
=
1.0
/
sqrt
(
four_pi
);
double
x
=
cosrth
;
...
...
@@ -1240,7 +1242,8 @@ void wmamp(
int
lm
,
int
idot
,
int
nsph
,
double
*
arg
,
double
*
u
,
double
*
up
,
double
*
un
,
C1
*
c1
)
{
std
::
complex
<
double
>
*
ylm
=
new
std
::
complex
<
double
>
[
1682
];
int
ylm_size
=
(
lm
+
1
)
*
(
lm
+
1
)
+
1
;
std
::
complex
<
double
>
*
ylm
=
new
std
::
complex
<
double
>
[
ylm_size
];
int
nlmp
=
lm
*
(
lm
+
2
)
+
2
;
ylm
[
nlmp
-
1
]
=
std
::
complex
<
double
>
(
0.0
,
0.0
);
if
(
idot
!=
0
)
{
...
...
@@ -1295,7 +1298,8 @@ void wmasp(
double
*
ups
,
double
*
uns
,
int
isq
,
int
ibf
,
int
inpol
,
int
lm
,
int
idot
,
int
nsph
,
double
*
argi
,
double
*
args
,
C1
*
c1
)
{
std
::
complex
<
double
>
*
ylm
=
new
std
::
complex
<
double
>
[
1682
];
int
ylm_size
=
(
lm
+
1
)
*
(
lm
+
1
)
+
1
;
std
::
complex
<
double
>
*
ylm
=
new
std
::
complex
<
double
>
[
ylm_size
];
int
nlmp
=
lm
*
(
lm
+
2
)
+
2
;
ylm
[
nlmp
-
1
]
=
std
::
complex
<
double
>
(
0.0
,
0.0
);
if
(
idot
!=
0
)
{
...
...
This diff is collapsed.
Click to expand it.
src/sphere/sphere.cpp
+
15
−
16
View file @
92c1d8b2
...
...
@@ -2,8 +2,12 @@
#include
<fstream>
#include
<string>
#include
<complex>
#ifndef INCLUDE_CONFIGURATION_H_
#include
"../include/Configuration.h"
#endif
#ifndef INCLUDE_SPH_SUBS_H_
#include
"../include/sph_subs.h"
#endif
using
namespace
std
;
...
...
@@ -15,13 +19,13 @@ void sphere() {
double
*
argi
,
*
args
,
*
gaps
;
double
th
,
ph
;
printf
(
"INFO: making legacy configuration ...
\n
"
);
ScattererConfiguration
*
conf
=
ScattererConfiguration
::
from_dedfb
(
"
../../test_data/sphere/
DEDFB"
);
conf
->
write_formatted
(
"c_OEDFB"
);
conf
->
write_binary
(
"c_TEDF"
);
ScattererConfiguration
*
conf
=
ScattererConfiguration
::
from_dedfb
(
"DEDFB
_sph
"
);
conf
->
write_formatted
(
"c_OEDFB
_sph
"
);
conf
->
write_binary
(
"c_TEDF
_sph
"
);
delete
conf
;
printf
(
"INFO: reading binary configuration ...
\n
"
);
ScattererConfiguration
*
sconf
=
ScattererConfiguration
::
from_binary
(
"c_TEDF"
);
GeometryConfiguration
*
gconf
=
GeometryConfiguration
::
from_legacy
(
"
../../test_data/sphere/
DSPH"
);
ScattererConfiguration
*
sconf
=
ScattererConfiguration
::
from_binary
(
"c_TEDF
_sph
"
);
GeometryConfiguration
*
gconf
=
GeometryConfiguration
::
from_legacy
(
"DSPH"
);
if
(
sconf
->
number_of_spheres
==
gconf
->
number_of_spheres
)
{
int
isq
,
ibf
;
double
cost
,
sint
,
cosp
,
sinp
;
...
...
@@ -49,18 +53,10 @@ void sphere() {
complex
<
double
>
*
vint
=
new
complex
<
double
>
[
16
];
int
jw
;
int
nsph
=
gconf
->
number_of_spheres
;
C1
*
c1
=
new
C1
(
nsph
,
gconf
->
l_max
);
C1
*
c1
=
new
C1
(
nsph
,
gconf
->
l_max
,
sconf
->
nshl_vec
,
sconf
->
iog_vec
);
for
(
int
i
=
0
;
i
<
nsph
;
i
++
)
{
c1
->
iog
[
i
]
=
sconf
->
iog_vec
[
i
];
c1
->
nshl
[
i
]
=
sconf
->
nshl_vec
[
i
];
c1
->
ros
[
i
]
=
sconf
->
radii_of_spheres
[
i
];
}
for
(
int
i
=
0
;
i
<
gconf
->
l_max
;
i
++
)
{
c1
->
rmi
[
i
][
0
]
=
complex
<
double
>
(
0.0
,
0.0
);
c1
->
rmi
[
i
][
1
]
=
complex
<
double
>
(
0.0
,
0.0
);
c1
->
rei
[
i
][
0
]
=
complex
<
double
>
(
0.0
,
0.0
);
c1
->
rei
[
i
][
1
]
=
complex
<
double
>
(
0.0
,
0.0
);
}
C2
*
c2
=
new
C2
(
nsph
,
5
,
gconf
->
npnt
,
gconf
->
npntts
);
argi
=
new
double
[
1
];
args
=
new
double
[
1
];
...
...
@@ -172,7 +168,7 @@ void sphere() {
double
exri
=
sqrt
(
sconf
->
exdc
);
fprintf
(
output
,
" REFR. INDEX OF EXTERNAL MEDIUM=%15.7lE
\n
"
,
exri
);
fstream
tppoan
;
tppoan
.
open
(
"c_TPPOAN"
,
ios
::
binary
|
ios
::
out
);
tppoan
.
open
(
"c_TPPOAN
_sph
"
,
ios
::
binary
|
ios
::
out
);
if
(
tppoan
.
is_open
())
{
int
imode
=
10
;
tppoan
.
write
(
reinterpret_cast
<
char
*>
(
&
imode
),
sizeof
(
int
));
...
...
@@ -250,7 +246,7 @@ void sphere() {
// This is the condition that writes the transition matrix to output.
int
is
=
1111
;
fstream
ttms
;
ttms
.
open
(
"c_TTMS"
,
ios
::
binary
|
ios
::
out
);
ttms
.
open
(
"c_TTMS
_sph
"
,
ios
::
binary
|
ios
::
out
);
if
(
ttms
.
is_open
())
{
ttms
.
write
(
reinterpret_cast
<
char
*>
(
&
is
),
sizeof
(
int
));
ttms
.
write
(
reinterpret_cast
<
char
*>
(
&
(
gconf
->
l_max
)),
sizeof
(
int
));
...
...
@@ -550,9 +546,12 @@ void sphere() {
}
delete
[]
cmul
;
delete
[]
cmullr
;
printf
(
"Done.
\n
"
);
}
else
{
// NSPH mismatch between geometry and scatterer configurations.
throw
UnrecognizedConfigurationException
(
"Inconsistent geometry and scatterer configurations."
);
}
delete
sconf
;
delete
gconf
;
}
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