Page MenuHomec4science

surface_generator.cpp
No OneTemporary

File Metadata

Created
Sun, Nov 10, 19:59

surface_generator.cpp

/**
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
*
* @section LICENSE
*
* Copyright (©) 2016 EPFL (Ecole Polytechnique Fédérale de
* Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des
* Solides)
*
* Tamaas is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Tamaas 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Tamaas. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
#include <iostream>
#include <map>
#include <fstream>
/* -------------------------------------------------------------------------- */
#include "surface_generator.hh"
#include "surface_generator_voss.hh"
#include "surface_generator_filter.hh"
#include "surface_generator_filter_bessel.hh"
#include "surface_generator_filter_fft.hh"
#include "surface_generator_crenel.hh"
#include "surface_generator_ellipsoid.hh"
#include "surface_statistics.hh"
/* -------------------------------------------------------------------------- */
__BEGIN_TAMAAS__
using namespace std;
/* -------------------------------------------------------------------------- */
/* Sort functions */
int sortAscend(const void * a, const void * b) {
return ( *(int*)a - *(int*)b );
}
/* -------------------------------------------------------------------------- */
int sortDescend(const void * a, const void * b) {
return ( *(int*)b - *(int*)a );
}
/* -------------------------------------------------------------------------- */
SurfaceGenerator::SurfaceGenerator():
rms(0.), random_seed(0),surface(NULL),gridsize(0) {
}
/* -------------------------------------------------------------------------- */
void SurfaceGenerator::Init() {
/* Post-process grid size */
if (gridsize % 2) {
SURFACE_FATAL("Grid size should even and is " << gridsize);
}
surface = new Surface<Real>(gridsize,1.);
return;
}
/* -------------------------------------------------------------------------- */
Real SurfaceGenerator::constrainRMS(){
int n = surface->size();
Real measured_rms = SurfaceStatistics::computeStdev(*surface);
std::cerr << " actual rms is " << rms << endl;
/* shift to center to mean value */
for (int i = 0 ; i < n ; ++i)
for (int j = 0 ; j < n ; ++j){
surface->at(i,j) *= rms/measured_rms;
}
return rms/measured_rms;
}
/* -------------------------------------------------------------------------- */
__END_TAMAAS__

Event Timeline