Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F88796675
surface_generator.hh
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, Oct 20, 17:47
Size
4 KB
Mime Type
text/x-c++
Expires
Tue, Oct 22, 17:47 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
21821748
Attached To
rTAMAAS tamaas
surface_generator.hh
View Options
/**
* @file surface_generator.hh
*
* @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 Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef SURFACE_GENERATOR_H
#define SURFACE_GENERATOR_H
/* -------------------------------------------------------------------------- */
#include "surface.hh"
#include <sstream>
#include <iostream>
#include <string>
#include <algorithm>
/* -------------------------------------------------------------------------- */
inline
void
trim
(
std
::
string
&
to_trim
)
{
size_t
first
=
to_trim
.
find_first_not_of
(
"
\t
"
);
if
(
first
!=
std
::
string
::
npos
)
{
size_t
last
=
to_trim
.
find_last_not_of
(
"
\t
"
);
to_trim
=
to_trim
.
substr
(
first
,
last
-
first
+
1
);
}
else
to_trim
=
""
;
}
/* -------------------------------------------------------------------------- */
class
SurfaceGenerator
{
public
:
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
//! constructor : takes a config file as input
SurfaceGenerator
(
const
std
::
string
&
inputfile
);
//! default constructor
SurfaceGenerator
();
//! default destructor
virtual
~
SurfaceGenerator
(){
delete
surface
;
};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
//! Build surface profile (array of heights)
virtual
Surface
<
Real
>
&
buildSurface
()
=
0
;
virtual
void
Init
();
Real
constrainRMS
();
protected
:
virtual
void
parseInputFile
(
std
::
ifstream
&
fp
)
=
0
;
template
<
typename
T
>
inline
void
readInput
(
const
std
::
string
&
arg
,
const
std
::
string
&
key
,
T
&
value
);
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public
:
int
&
getGridSize
(){
return
gridsize
;};
void
setGridSize
(
int
gsz
){
this
->
gridsize
=
gsz
;};
Real
&
getRMS
(){
return
rms
;};
long
&
getRandomSeed
(){
return
random_seed
;};
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected
:
Real
rms
;
/* The RMS for the rough surface */
long
random_seed
;
/* A random seed */
std
::
string
configfile
;
Surface
<
Real
>
*
surface
;
int
gridsize
;
};
/* -------------------------------------------------------------------------- */
template
<
typename
T
>
inline
void
SurfaceGenerator
::
readInput
(
const
std
::
string
&
line
,
const
std
::
string
&
key
,
T
&
value
){
std
::
string
arg
;
std
::
stringstream
str
(
line
);
str
>>
arg
;
trim
(
arg
);
if
(
key
==
arg
){
str
>>
value
;
}
}
/* -------------------------------------------------------------------------- */
#endif
Event Timeline
Log In to Comment