Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
iwr
amdis
Commits
beb965bd
Commit
beb965bd
authored
Aug 01, 2018
by
Praetorius, Simon
Browse files
Added clamp expression
parent
49c90c0c
Changes
7
Show whitespace changes
Inline
Side-by-side
AMDiS/cmake/CMakeLists.txt
View file @
beb965bd
...
...
@@ -182,6 +182,11 @@ list(APPEND AMDIS_SRC
${
SOURCE_DIR
}
/ProblemStatDbg.cc
)
if
(
ENABLE_MPI
)
enable_mpi
(
COMPILEFLAGS AMDIS_INCLUDE_DIRS _
)
list
(
APPEND COMPILEFLAGS
"-DHAVE_MPI=1"
)
endif
(
ENABLE_MPI
)
include
(
amdis_parallel
)
include
(
muparser
)
...
...
AMDiS/cmake/amdis_parallel.cmake
View file @
beb965bd
...
...
@@ -20,7 +20,6 @@ if (ENABLE_PARALLEL_DOMAIN)
list
(
APPEND COMPILEFLAGS
"-DHAVE_PARALLEL_DOMAIN_AMDIS=1"
)
enable_mpi
(
COMPILEFLAGS AMDIS_INCLUDE_DIRS _
)
enable_petsc
(
COMPILEFLAGS AMDIS_INCLUDE_DIRS _
)
# add support for the zoltan library
...
...
AMDiS/cmake3/amdis_parallel.cmake
View file @
beb965bd
...
...
@@ -22,7 +22,6 @@ if (ENABLE_PARALLEL_DOMAIN)
target_compile_definitions
(
amdis_parallel INTERFACE
HAVE_PARALLEL_DOMAIN_AMDIS=1
)
target_enable_mpi
(
amdis_parallel INTERFACE
)
target_enable_petsc
(
amdis_parallel INTERFACE
)
# add support for the zoltan library
...
...
AMDiS/src/expressions/cmath_expr.hpp
View file @
beb965bd
...
...
@@ -490,7 +490,7 @@ namespace AMDiS
int
getDegree
()
const
{
return
std
::
max
(
super
::
term1
.
getDegree
(),
super
::
term2
.
getDegree
());
return
std
::
max
(
super
::
term1
.
getDegree
(),
super
::
term2
.
getDegree
())
+
2
;
}
inline
value_type
operator
()(
const
int
&
iq
)
const
...
...
@@ -514,7 +514,7 @@ namespace AMDiS
int
getDegree
()
const
{
return
std
::
max
(
super
::
term1
.
getDegree
(),
super
::
term2
.
getDegree
());
return
std
::
max
(
super
::
term1
.
getDegree
(),
super
::
term2
.
getDegree
())
+
2
;
}
inline
value_type
operator
()(
const
int
&
iq
)
const
...
...
@@ -525,6 +525,69 @@ namespace AMDiS
std
::
string
str
()
const
{
return
std
::
string
(
"min("
)
+
super
::
term1
.
str
()
+
", "
+
super
::
term2
.
str
()
+
")"
;
}
};
template
<
typename
Term1
>
struct
Clamp
:
public
LazyOperatorTerm1
<
Term1
>
{
typedef
LazyOperatorTerm1
<
Term1
>
super
;
typedef
typename
Term1
::
value_type
value_type
;
Clamp
(
const
Term1
&
term1_
,
value_type
const
&
lo
=
0.0
,
value_type
const
&
hi
=
1.0
)
:
super
(
term1_
)
,
lo
(
lo
)
,
hi
(
hi
)
{
assert
(
!
(
hi
<
lo
)
);
}
int
getDegree
()
const
{
return
super
::
term
.
getDegree
()
+
2
;
}
inline
value_type
operator
()(
const
int
&
iq
)
const
{
value_type
v
=
super
::
term
(
iq
);
return
v
<
lo
?
lo
:
hi
<
v
?
hi
:
v
;
}
std
::
string
str
()
const
{
return
std
::
string
(
"clamp("
)
+
super
::
term
.
str
()
+
", "
+
lo
+
", "
<<
hi
<<
")"
;
}
value_type
lo
,
hi
;
};
// derivative of clamp
template
<
typename
Term1
>
struct
DClamp
:
public
LazyOperatorTerm1
<
Term1
>
{
typedef
LazyOperatorTerm1
<
Term1
>
super
;
typedef
typename
Term1
::
value_type
value_type
;
DClamp
(
const
Term1
&
term1_
,
value_type
const
&
lo
=
0.0
,
value_type
const
&
hi
=
1.0
)
:
super
(
term1_
)
,
lo
(
lo
)
,
hi
(
hi
)
{
assert
(
!
(
hi
<
lo
)
);
}
int
getDegree
()
const
{
return
2
;
}
inline
value_type
operator
()(
const
int
&
iq
)
const
{
value_type
v
=
super
::
term
(
iq
);
return
v
<
lo
?
value_type
(
0
)
:
hi
<
v
?
value_type
(
0
)
:
value_type
(
1
);
}
std
::
string
str
()
const
{
return
std
::
string
(
"dclamp("
)
+
super
::
term
.
str
()
+
", "
+
lo
+
", "
<<
hi
<<
")"
;
}
value_type
lo
,
hi
;
};
}
// end namespace expressions
...
...
@@ -742,6 +805,22 @@ namespace AMDiS
expressions
::
Atanh
<
Term
>
>::
type
atanh
(
const
Term
&
t
)
{
return
expressions
::
Atanh
<
Term
>
(
t
);
}
//______________________________________________________________________________
// clamp between lo and hi
template
<
typename
Term
,
typename
T
=
typename
Term
::
value_type
>
inline
typename
boost
::
enable_if
<
typename
traits
::
is_expr
<
Term
>::
type
,
expressions
::
Clamp
<
Term
>
>::
type
clamp
(
const
Term
&
t
,
T
const
&
lo
,
T
const
&
hi
)
{
return
expressions
::
Clamp
<
Term
>
(
t
,
lo
,
hi
);
}
// derivative of clamp between lo and hi
template
<
typename
Term
,
typename
T
=
typename
Term
::
value_type
>
inline
typename
boost
::
enable_if
<
typename
traits
::
is_expr
<
Term
>::
type
,
expressions
::
DClamp
<
Term
>
>::
type
dclamp
(
const
Term
&
t
,
T
const
&
lo
,
T
const
&
hi
)
{
return
expressions
::
DClamp
<
Term
>
(
t
,
lo
,
hi
);
}
}
// end namespace AMDiS
#endif // AMDIS_CMATH_EXPRESSION_HPP
AMDiS/src/expressions/diff_expr.hpp
View file @
beb965bd
...
...
@@ -276,6 +276,39 @@ namespace AMDiS
template
<
typename
Term
,
typename
Id
>
struct
Diff
<
Id
,
Abs
<
Term
>
>
{};
// not yet implemented
template
<
typename
Id
,
typename
Term
,
typename
Direction
>
class
Diff
<
Id
,
Clamp
<
Term
>
,
Direction
>
{
typedef
typename
Simplify
<
typename
Diff
<
Id
,
Term
>::
type
>::
type
D
;
typedef
typename
Simplify
<
typename
Diff
<
Id
,
Term
,
Direction
>::
dir_type
>::
type
D_
;
public:
typedef
Clamp
<
Term
>
original_type
;
typedef
typename
Simplify
<
Mult
<
D
,
DClamp
<
Term
>>
>::
type
type
;
typedef
typename
Simplify
<
Mult
<
D_
,
DClamp
<
Term
>>
>::
type
dir_type
;
static
type
eval
(
original_type
const
&
t
)
{
return
simplify
(
diff
<
Id
>
(
t
.
term
)
*
dclamp
(
t
.
term
,
t
.
lo
,
t
.
hi
));
}
static
dir_type
eval
(
original_type
const
&
t
,
Direction
const
&
d
)
{
return
simplify
(
diff
<
Id
>
(
t
.
term
,
d
)
*
dclamp
(
t
.
term
,
t
.
lo
,
t
.
hi
));
}
};
template
<
typename
Id
,
typename
Term
,
typename
Direction
>
struct
Diff
<
Id
,
DClamp
<
Term
>
,
Direction
>
{
typedef
DClamp
<
Term
>
original_type
;
typedef
CValue
<
0
>
type
;
typedef
CValue
<
0
>
dir_type
;
static
type
eval
(
Term
const
&
t
)
{
return
CValue
<
0
>
();
}
static
dir_type
eval
(
Term
const
&
t
,
Direction
const
&
d
)
{
return
CValue
<
0
>
();
}
};
}
// end namespace expressions
...
...
@@ -284,7 +317,7 @@ namespace AMDiS
namespace
expressions
{
template
<
typename
Id
,
int
I
,
typename
Term
,
typename
Direction
>
class
Diff
<
Id
,
Pow
<
I
,
Term
>
,
Direction
>
class
Diff
<
Id
,
Pow
<
I
,
Term
>
,
Direction
>
{
typedef
typename
Simplify
<
typename
Diff
<
Id
,
Term
>::
type
>::
type
D
;
typedef
typename
Simplify
<
typename
Diff
<
Id
,
Term
,
Direction
>::
dir_type
>::
type
D_
;
...
...
AMDiS/src/expressions/simplify_expr.hpp
View file @
beb965bd
...
...
@@ -65,6 +65,15 @@ namespace AMDiS
namespace
expressions
{
/// no simplification
template
<
class
T
>
struct
Simplify
<
RValue
<
T
>
>
{
typedef
RValue
<
T
>
type
;
static
type
eval
(
RValue
<
T
>
const
&
t
)
{
return
t
;
}
};
/// -(N) -> (-N)
template
<
int
N
>
struct
Simplify
<
Negative
<
CValue
<
N
>
>
>
...
...
extensions/demo/cahn_hilliard/CMakeLists.txt
View file @
beb965bd
...
...
@@ -2,22 +2,16 @@ project("cahn_hilliard_demo")
cmake_minimum_required
(
VERSION 2.8
)
#find_package(AMDIS REQUIRED COMPONENTS umfpack )
find_package
(
AMDIS REQUIRED
)
if
(
AMDIS_FOUND
)
message
(
"amdis was found
\n
"
)
include
(
${
AMDIS_USE_FILE
}
)
SET
(
BASIS_LIBS
${
AMDIS_LIBRARIES
}
)
endif
(
AMDIS_FOUND
)
find_package
(
AMDIS REQUIRED PARALLEL
)
set
(
ch src/cahnHilliard.cc
)
add_executable
(
"ch"
${
ch
}
)
target_link_libraries
(
"ch"
${
BASIS_LIBS
}
)
target_link_libraries
(
"ch"
AMDiS
)
set
(
ch_dd src/cahnHilliard_dd.cc src/CahnHilliard_DD.cc
)
add_executable
(
"ch_dd"
${
ch_dd
}
)
target_link_libraries
(
"ch_dd"
${
BASIS_LIBS
}
)
target_link_libraries
(
"ch_dd"
AMDiS
)
set
(
ch_shell src/cahnHilliard_shell.cc
)
add_executable
(
"ch_shell"
${
ch_shell
}
)
target_link_libraries
(
"ch_shell"
${
BASIS_LIBS
}
)
target_link_libraries
(
"ch_shell"
AMDiS
)
Write
Preview
Supports
Markdown
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