Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Praetorius, Simon
dune-amdis
Commits
e034a097
Commit
e034a097
authored
Nov 01, 2018
by
Praetorius, Simon
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'issue/clamp_operations' into 'develop'
Issue/clamp operations See merge request
!50
parents
71cbbe25
4ac29286
Pipeline
#1382
passed with stage
in 26 minutes and 9 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
15 deletions
+63
-15
src/amdis/gridfunctions/OperationsGridFunction.hpp
src/amdis/gridfunctions/OperationsGridFunction.hpp
+8
-0
src/amdis/operations/Arithmetic.hpp
src/amdis/operations/Arithmetic.hpp
+21
-15
src/amdis/operations/CMath.hpp
src/amdis/operations/CMath.hpp
+34
-0
No files found.
src/amdis/gridfunctions/OperationsGridFunction.hpp
View file @
e034a097
...
...
@@ -88,6 +88,14 @@ namespace AMDiS
return
invokeAtQP
(
Operation
::
AbsMin
{},
std
::
forward
<
Lhs
>
(
lhs
),
std
::
forward
<
Rhs
>
(
rhs
));
}
/// \brief Applies \ref Operation::Clamp to GridFunction. \relates FunctorGridFunction
template
<
class
V
,
class
T
,
REQUIRES
(
Concepts
::
AnyGridFunction
<
V
>)
>
auto
clamp
(
V
&&
v
,
T
const
&
lo
,
T
const
&
hi
)
{
return
invokeAtQP
(
Operation
::
Clamp
<
T
>
{
lo
,
hi
},
std
::
forward
<
V
>
(
v
));
}
/// \brief Applies \ref Operation::Sqr to GridFunction. \relates FunctorGridFunction
template
<
class
T
,
REQUIRES
(
Concepts
::
AnyGridFunction
<
T
>)
>
...
...
src/amdis/operations/Arithmetic.hpp
View file @
e034a097
...
...
@@ -169,9 +169,27 @@ namespace AMDiS
// -------------------------------------------------------------------------
// forward declaration
template
<
int
p
>
struct
PowImpl
;
template
<
int
p
>
struct
PowType
{
using
type
=
PowImpl
<
p
>
;
};
template
<
>
struct
PowType
<
1
>
{
using
type
=
Id
;
};
template
<
>
struct
PowType
<
0
>
{
using
type
=
One
;
};
template
<
int
p
>
using
Pow
=
typename
PowType
<
p
>::
type
;
using
Sqr
=
Pow
<
2
>
;
/// Functor that represents x^p
template
<
int
p
>
struct
Pow
struct
Pow
Impl
{
static_assert
(
p
>
1
,
"Exponent in power must be non-negative!"
);
...
...
@@ -181,29 +199,17 @@ namespace AMDiS
return
Math
::
pow
<
p
>
(
x
);
}
friend
int
order
(
Pow
,
int
d
)
friend
int
order
(
Pow
Impl
,
int
d
)
{
return
p
*
d
;
}
friend
auto
partial
(
Pow
,
index_t
<
0
>
)
friend
auto
partial
(
Pow
Impl
,
index_t
<
0
>
)
{
return
compose
(
Multiplies
{},
StaticConstant
<
int
,
p
>
{},
Pow
<
p
-
1
>
{});
}
};
using
Sqr
=
Pow
<
2
>
;
/// \see Pow
template
<
>
struct
Pow
<
1
>
:
public
Id
{};
/// \see Pow
template
<
>
struct
Pow
<
0
>
:
public
Zero
{};
/// Functor that represents x^p, \see \ref Pow
struct
Pow_
{
...
...
src/amdis/operations/CMath.hpp
View file @
e034a097
...
...
@@ -117,6 +117,40 @@ namespace AMDiS
}
};
template
<
class
T
>
struct
Clamp
{
Clamp
(
T
const
&
lo
,
T
const
&
hi
)
:
lo_
(
lo
)
,
hi_
(
hi
)
{
assert
(
lo
<
hi
);
}
constexpr
auto
operator
()
(
T
const
&
v
)
const
{
return
v
<
lo_
?
lo_
:
hi_
<
v
?
hi_
:
v
;
}
struct
DClamp
{
constexpr
auto
operator
()
(
T
const
&
v
)
const
{
return
v
<
lo_
?
T
(
0
)
:
hi_
<
v
?
T
(
0
)
:
T
(
1
);
}
T
lo_
,
hi_
;
};
constexpr
friend
auto
partial
(
Clamp
c
,
index_t
<
0
>
)
{
return
DClamp
{
c
.
lo_
,
c
.
hi_
};
}
T
lo_
,
hi_
;
};
/** @} **/
}
// end namespace Operation
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment