Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cdo
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mpim-sw
cdo
Commits
ff695071
Commit
ff695071
authored
2 years ago
by
Volker Neff
Browse files
Options
Downloads
Patches
Plain Diff
rename vars
parent
23270897
No related branches found
Branches containing commit
No related tags found
1 merge request
!6
Draft: [WIP] New Field Architekture
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/field_operation.inl
+25
-25
25 additions, 25 deletions
src/field_operation.inl
with
25 additions
and
25 deletions
src/field_operation.inl
+
25
−
25
View file @
ff695071
...
...
@@ -80,28 +80,28 @@ template<
>
inline auto
field_operation(
FunctionFloat f
f
, FunctionDouble f
d
,
FunctionFloat f
unctionFloat
, FunctionDouble f
unctionDouble
,
Field_T_& field,
ARGS... args
)
-> decltype(f
f
(std::declval<typename FieldX_t<Field_T_>::typeFloat&>(), args...)) {
-> decltype(f
unctionFloat
(std::declval<typename FieldX_t<Field_T_>::typeFloat&>(), args...)) {
using typeFloat = typename FieldX_t<Field_T_>::typeFloat;
using typeDouble = typename FieldX_t<Field_T_>::typeDouble;
// check that f
f and fd
has the same signatur and specialy the same return type
using returnTypeFunctionFloat = decltype(f
f
(std::declval<typeFloat&>(), args...));
using returnTypeFunctionDouble = decltype(f
d
(std::declval<typeDouble&>(), args...));
// check that f
unctionFloat and functionDouble
has the same signatur and specialy the same return type
using returnTypeFunctionFloat = decltype(f
unctionFloat
(std::declval<typeFloat&>(), args...));
using returnTypeFunctionDouble = decltype(f
unctionDouble
(std::declval<typeDouble&>(), args...));
static_assert(std::is_same<returnTypeFunctionFloat, returnTypeFunctionDouble>::value,
"f
f and fd
has not the same return types");
"f
unction float and functionDouble
has not the same return types");
// Fail fast if field is not from type `Field_t` or `const Field_t`
static_assert(check_T_is_fielX_t<Field_T_>(), "field must be from type 'Field_t' or 'const Field_t' or 'Field3D_t' or 'const Field3D_t'.");
if(std::holds_alternative<typeFloat>(field)) {
return f
f
(std::get<typeFloat>(field), args...);
return f
unctionFloat
(std::get<typeFloat>(field), args...);
} else if(std::holds_alternative<typeDouble>(field)) {
return f
d
(std::get<typeDouble>(field), args...);
return f
unctionDouble
(std::get<typeDouble>(field), args...);
} else {
throw std::runtime_error("Not supported Type");
}
...
...
@@ -118,10 +118,10 @@ template<
typename... ARGS
>
inline auto
field_operation2(FunctionFloat f
f
, FunctionDouble f
d
,
field_operation2(FunctionFloat f
unctionFloat
, FunctionDouble f
unctionDouble
,
Field_T1_& field1, Field_T2_& field2,
ARGS... args)
-> decltype(f
f
(
-> decltype(f
unctionFloat
(
std::declval<typename FieldX_t<Field_T1_>::typeFloat&>(),
std::declval<typename FieldX_t<Field_T2_>::typeFloat&>(),
args...)) {
...
...
@@ -129,11 +129,11 @@ ARGS... args)
using typeFloat = typename FieldX_t<Field_T1_>::typeFloat;
using typeDouble = typename FieldX_t<Field_T1_>::typeDouble;
// check that f
f and fd
has the same signatur and specialy the same return type
using returnTypeFunctionFloat = decltype(f
f
(std::declval<typeFloat&>(), std::declval<typeFloat&>(), args...));
using returnTypeFunctionDouble = decltype(f
d
(std::declval<typeDouble&>(), std::declval<typeDouble&>(), args...));
// check that f
unctionFloat and functionDouble
has the same signatur and specialy the same return type
using returnTypeFunctionFloat = decltype(f
unctionFloat
(std::declval<typeFloat&>(), std::declval<typeFloat&>(), args...));
using returnTypeFunctionDouble = decltype(f
unctionDouble
(std::declval<typeDouble&>(), std::declval<typeDouble&>(), args...));
static_assert(std::is_same<returnTypeFunctionFloat, returnTypeFunctionDouble>::value,
"f
f and fd
has not the same return types");
"f
unction float and functionDouble
has not the same return types");
// Fail fast if field is not from type `Field_t` or `const Field_t`
static_assert(check_T_is_fielX_t<Field_T1_>(), "field1 must be from type 'Field_t' or 'const Field_t' or 'Field3D_t' or 'const Field3D_t'");
...
...
@@ -145,9 +145,9 @@ ARGS... args)
}
if(std::holds_alternative<typeFloat>(field1)) {
return f
f
(std::get<typeFloat>(field1), std::get<typeFloat>(field2), args...);
return f
unctionFloat
(std::get<typeFloat>(field1), std::get<typeFloat>(field2), args...);
} else if(std::holds_alternative<typeDouble>(field1)) {
return f
d
(std::get<typeDouble>(field1), std::get<typeDouble>(field2), args...);
return f
unctionDouble
(std::get<typeDouble>(field1), std::get<typeDouble>(field2), args...);
} else {
throw std::runtime_error("Not supported Type");
}
...
...
@@ -175,7 +175,7 @@ field_operation2DiffType(
using typeFloat = typename FieldX_t<Field_T1_>::typeFloat;
using typeDouble = typename FieldX_t<Field_T1_>::typeDouble;
// check that f
f and fd
has the same signatur and specialy the same return type
// check that f
unctionFloat and functionDouble
has the same signatur and specialy the same return type
using returnTypeFunctionFloatFloat = decltype(f(std::declval<typeFloat&>(), std::declval<typeFloat&>(), args...));
using returnTypeFunctionFloatDouble = decltype(f(std::declval<typeFloat&>(), std::declval<typeDouble&>(), args...));
using returnTypeFunctionDoubleDouble = decltype(f(std::declval<typeDouble&>(), std::declval<typeDouble&>(), args...));
...
...
@@ -229,11 +229,11 @@ template<
>
inline auto
field_operation3(
FunctionFloat f
f
, FunctionDouble f
d
,
FunctionFloat f
unctionFloat
, FunctionDouble f
unctionDouble
,
Field_T1_& field1, Field_T2_& field2, Field_T3_& field3,
ARGS... args
)
-> decltype(f
f
(
-> decltype(f
unctionFloat
(
std::declval<typename FieldX_t<Field_T1_>::typeFloat&>(),
std::declval<typename FieldX_t<Field_T2_>::typeFloat&>(),
std::declval<typename FieldX_t<Field_T3_>::typeFloat&>(),
...
...
@@ -242,11 +242,11 @@ field_operation3(
using typeFloat = typename FieldX_t<Field_T1_>::typeFloat;
using typeDouble = typename FieldX_t<Field_T1_>::typeDouble;
// check that f
f and fd
has the same signatur and specialy the same return type
using returnTypeFunctionFloat = decltype(f
f
(std::declval<typeFloat&>(), std::declval<typeFloat&>(), std::declval<typeFloat&>(), args...));
using returnTypeFunctionDouble = decltype(f
d
(std::declval<typeDouble&>(), std::declval<typeDouble&>(), std::declval<typeDouble&>(), args...));
// check that f
unctionFloat and functionDouble
has the same signatur and specialy the same return type
using returnTypeFunctionFloat = decltype(f
unctionFloat
(std::declval<typeFloat&>(), std::declval<typeFloat&>(), std::declval<typeFloat&>(), args...));
using returnTypeFunctionDouble = decltype(f
unctionDouble
(std::declval<typeDouble&>(), std::declval<typeDouble&>(), std::declval<typeDouble&>(), args...));
static_assert(std::is_same<returnTypeFunctionFloat, returnTypeFunctionDouble>::value,
"f
f and fd
has not the same return types");
"f
unction float and functionDouble
has not the same return types");
// Fail fast if field is not from type `Field_t` or `const Field_t`
static_assert(check_T_is_fielX_t<Field_T1_>(), "field1 must be from type 'Field_t' or 'const Field_t' or 'Field3D_t' or 'const Field3D_t'");
...
...
@@ -259,9 +259,9 @@ field_operation3(
}
if(std::holds_alternative<typeFloat>(field1)) {
return f
f
(std::get<typeFloat>(field1), std::get<typeFloat>(field2), std::get<typeFloat>(field3), args...);
return f
unctionFloat
(std::get<typeFloat>(field1), std::get<typeFloat>(field2), std::get<typeFloat>(field3), args...);
} else if(std::holds_alternative<typeDouble>(field1)) {
return f
d
(std::get<typeDouble>(field1), std::get<typeDouble>(field2), std::get<typeDouble>(field3),args...);
return f
unctionDouble
(std::get<typeDouble>(field1), std::get<typeDouble>(field2), std::get<typeDouble>(field3),args...);
} else {
throw std::runtime_error("Not supported Type");
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment