Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91763964
surface.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
Thu, Nov 14, 05:30
Size
6 KB
Mime Type
text/x-c++
Expires
Sat, Nov 16, 05:30 (2 d)
Engine
blob
Format
Raw Data
Handle
22284107
Attached To
rTAMAAS tamaas
surface.cpp
View Options
/**
* @file
*
* @author Lucas Frérot <lucas.frerot@epfl.ch>
*
* @section LICENSE
*
* Copyright (©) 2017 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 "wrap.hh"
#include "isopowerlaw.hh"
#include "surface_generator_filter.hh"
#include "surface_generator_filter_fft.hh"
#include <pybind11/stl.h>
/* -------------------------------------------------------------------------- */
__BEGIN_TAMAAS__
/* -------------------------------------------------------------------------- */
namespace
wrap
{
using
namespace
py
::
literals
;
/* -------------------------------------------------------------------------- */
template
<
UInt
dim
>
class
PyFilter
:
public
Filter
<
dim
>
{
public
:
using
Filter
<
dim
>::
Filter
;
// Overriding pure virtual functions
void
computeFilter
(
GridHermitian
<
Real
,
dim
>&
filter_coefficients
)
const
override
{
PYBIND11_OVERLOAD_PURE
(
void
,
Filter
<
dim
>
,
computeFilter
,
filter_coefficients
);
}
};
template
<
UInt
dim
>
void
wrapFilter
(
py
::
module
&
mod
)
{
auto
name
=
makeDimensionName
(
"Filter"
,
dim
);
py
::
class_
<
Filter
<
dim
>
,
PyFilter
<
dim
>>
(
mod
,
name
.
c_str
())
.
def
(
py
::
init
<>
())
.
def
(
"computeFilter"
,
&
Filter
<
dim
>::
computeFilter
);
}
/* -------------------------------------------------------------------------- */
template
<
UInt
dim
>
void
wrapIsopowerlaw
(
py
::
module
&
mod
)
{
std
::
string
name
=
makeDimensionName
(
"Isopowerlaw"
,
dim
);
py
::
class_
<
Isopowerlaw
<
dim
>
,
Filter
<
dim
>>
(
mod
,
name
.
c_str
())
.
def
(
py
::
init
<>
())
.
def_property
(
"q0"
,
&
Isopowerlaw
<
dim
>::
getQ0
,
&
Isopowerlaw
<
dim
>::
setQ0
)
.
def_property
(
"q1"
,
&
Isopowerlaw
<
dim
>::
getQ1
,
&
Isopowerlaw
<
dim
>::
setQ1
)
.
def_property
(
"q2"
,
&
Isopowerlaw
<
dim
>::
getQ2
,
&
Isopowerlaw
<
dim
>::
setQ2
)
.
def_property
(
"hurst"
,
&
Isopowerlaw
<
dim
>::
getHurst
,
&
Isopowerlaw
<
dim
>::
setHurst
)
.
def
(
"rmsHeights"
,
&
Isopowerlaw
<
dim
>::
rmsHeights
)
.
def
(
"moments"
,
&
Isopowerlaw
<
dim
>::
moments
)
.
def
(
"alpha"
,
&
Isopowerlaw
<
dim
>::
alpha
)
.
def
(
"rmsSlopes"
,
&
Isopowerlaw
<
dim
>::
rmsSlopes
)
// legacy wrapper code
.
def
(
"getQ0"
,
&
Isopowerlaw
<
dim
>::
getQ0
,
py
::
return_value_policy
::
reference
)
.
def
(
"getQ1"
,
&
Isopowerlaw
<
dim
>::
getQ1
,
py
::
return_value_policy
::
reference
)
.
def
(
"getQ2"
,
&
Isopowerlaw
<
dim
>::
getQ2
,
py
::
return_value_policy
::
reference
)
.
def
(
"setQ0"
,
&
Isopowerlaw
<
dim
>::
setQ0
,
py
::
return_value_policy
::
reference
)
.
def
(
"setQ1"
,
&
Isopowerlaw
<
dim
>::
setQ1
,
py
::
return_value_policy
::
reference
)
.
def
(
"setQ2"
,
&
Isopowerlaw
<
dim
>::
setQ2
,
py
::
return_value_policy
::
reference
)
.
def
(
"setHurst"
,
&
Isopowerlaw
<
dim
>::
setHurst
)
.
def
(
"getHurst"
,
&
Isopowerlaw
<
dim
>::
getHurst
,
py
::
return_value_policy
::
reference
);
}
/* -------------------------------------------------------------------------- */
template
<
UInt
dim
>
void
wrapSurfaceGeneratorFilter
(
py
::
module
&
mod
)
{
std
::
string
name
=
makeDimensionName
(
"SurfaceGeneratorFilter"
,
dim
);
py
::
class_
<
SurfaceGeneratorFilter
<
dim
>>
(
mod
,
name
.
c_str
())
.
def
(
py
::
init
<>
())
.
def
(
"buildSurface"
,
&
SurfaceGeneratorFilter
<
dim
>::
buildSurface
,
"Build rough surface"
)
.
def
(
"setFilter"
,
&
SurfaceGeneratorFilter
<
dim
>::
setFilter
,
"Set PSD filter"
,
"filter"
_a
)
.
def
(
"setSizes"
,
(
void
(
SurfaceGeneratorFilter
<
dim
>::*
)(
const
std
::
array
<
UInt
,
dim
>&
))
&
SurfaceGeneratorFilter
<
dim
>::
setSizes
,
"surface_sizes"
_a
)
.
def_property
(
"random_seed"
,
&
SurfaceGeneratorFilter
<
dim
>::
getRandomSeed
,
&
SurfaceGeneratorFilter
<
dim
>::
setRandomSeed
)
// legacy wrapper code
.
def
(
"setRandomSeed"
,
&
SurfaceGeneratorFilter
<
dim
>::
setRandomSeed
,
"[[Deprecated: use property]]"
);
}
/* -------------------------------------------------------------------------- */
// Legacy wrap
void
wrapSurfaceGeneratorFilterFFT
(
py
::
module
&
mod
)
{
py
::
class_
<
SurfaceGeneratorFilterFFT
>
(
mod
,
"SurfaceGeneratorFilterFFT"
)
.
def
(
py
::
init
<>
())
.
def
(
"getQ0"
,
[](
SurfaceGeneratorFilterFFT
&
f
)
{
return
smart_pointer
<
UInt
>
(
&
f
.
getQ0
());
})
.
def
(
"getQ1"
,
[](
SurfaceGeneratorFilterFFT
&
f
)
{
return
smart_pointer
<
UInt
>
(
&
f
.
getQ1
());
})
.
def
(
"getQ2"
,
[](
SurfaceGeneratorFilterFFT
&
f
)
{
return
smart_pointer
<
UInt
>
(
&
f
.
getQ2
());
})
.
def
(
"getHurst"
,
[](
SurfaceGeneratorFilterFFT
&
f
)
{
return
smart_pointer
<
Real
>
(
&
f
.
getHurst
());
})
.
def
(
"analyticalRMS"
,
&
SurfaceGeneratorFilterFFT
::
analyticalRMS
)
.
def
(
"buildSurface"
,
&
SurfaceGeneratorFilterFFT
::
buildSurface
)
.
def
(
"getGridSize"
,
[](
SurfaceGeneratorFilterFFT
&
f
)
{
return
smart_pointer
<
UInt
>
(
&
f
.
getGridSize
());
})
.
def
(
"getRandomSeed"
,
[](
SurfaceGeneratorFilterFFT
&
f
)
{
return
smart_pointer
<
long
>
(
&
f
.
getRandomSeed
());
})
.
def
(
"getRMS"
,
[](
SurfaceGeneratorFilterFFT
&
f
)
{
return
smart_pointer
<
Real
>
(
&
f
.
getRMS
());
})
.
def
(
"Init"
,
&
SurfaceGeneratorFilterFFT
::
Init
);
}
/* -------------------------------------------------------------------------- */
void
wrapSurface
(
py
::
module
&
mod
)
{
wrapFilter
<
1
>
(
mod
);
wrapFilter
<
2
>
(
mod
);
wrapIsopowerlaw
<
1
>
(
mod
);
wrapIsopowerlaw
<
2
>
(
mod
);
wrapSurfaceGeneratorFilter
<
1
>
(
mod
);
wrapSurfaceGeneratorFilter
<
2
>
(
mod
);
// legacy wrap
wrapSurfaceGeneratorFilterFFT
(
mod
);
}
}
// namespace wrap
/* -------------------------------------------------------------------------- */
__END_TAMAAS__
Event Timeline
Log In to Comment