Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F84396006
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
Sun, Sep 22, 14:53
Size
2 KB
Mime Type
text/x-c++
Expires
Tue, Sep 24, 14:53 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
21007567
Attached To
rTAMAAS tamaas
surface_generator_random_phase.cpp
View Options
/*
* SPDX-License-Indentifier: AGPL-3.0-or-later
*
* 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(
[] CUDA_LAMBDA(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