Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F78841907
surface_generator_random_phase.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Aug 23, 07:03
Size
2 KB
Mime Type
text/x-c++
Expires
Sun, Aug 25, 07:03 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
20111324
Attached To
rTAMAAS tamaas
surface_generator_random_phase.cpp
View Options
/**
* @file
* @section LICENSE
*
* Copyright (©) 2016-2021 EPFL (École Polytechnique Fédérale de Lausanne),
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
#include "surface_generator_random_phase.hh"
#include <iostream>
/* -------------------------------------------------------------------------- */
namespace
tamaas
{
/* -------------------------------------------------------------------------- */
template
<
UInt
dim
>
Grid
<
Real
,
dim
>&
SurfaceGeneratorRandomPhase
<
dim
>::
buildSurface
()
{
if
(
this
->
grid
.
dataSize
()
==
0
)
TAMAAS_EXCEPTION
(
"the size of the grid is zero, did you call setSizes() ?"
);
if
(
this
->
filter
==
nullptr
)
TAMAAS_EXCEPTION
(
"spectrum is null, did you call setSpectrum() ?"
);
// Resizing arrays
auto
hermitian_dim
=
GridHermitian
<
Real
,
dim
>::
hermitianDimensions
(
this
->
grid
.
sizes
());
this
->
white_noise
.
resize
(
hermitian_dim
);
this
->
filter_coefficients
.
resize
(
hermitian_dim
);
/// Generating white noise with uniform distribution for phase
this
->
template
generateWhiteNoise
<
uniform_real_distribution
<
Real
>>
();
/// Applying filters
this
->
filter
->
computeFilter
(
this
->
filter_coefficients
);
Loop
::
loop
([](
Complex
&
coeff
,
Real
&
phase
)
{
coeff
*=
thrust
::
polar
(
1.
,
2
*
M_PI
*
phase
);
},
this
->
filter_coefficients
,
this
->
white_noise
);
this
->
engine
->
backward
(
this
->
grid
,
this
->
filter_coefficients
);
/// Normalizing surface for hrms independent of number of points
this
->
grid
*=
this
->
grid
.
globalDataSize
();
return
this
->
grid
;
}
/* -------------------------------------------------------------------------- */
template
class
SurfaceGeneratorRandomPhase
<
1
>
;
template
class
SurfaceGeneratorRandomPhase
<
2
>
;
/* -------------------------------------------------------------------------- */
}
// namespace tamaas
Event Timeline
Log In to Comment