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
2cfe36e5
Commit
2cfe36e5
authored
2 years ago
by
Volker Neff
Browse files
Options
Downloads
Patches
Plain Diff
changes at Field_t
parent
3bd34c51
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!6
Draft: [WIP] New Field Architekture
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/field.h
+50
-1
50 additions, 1 deletion
src/field.h
with
50 additions
and
1 deletion
src/field.h
+
50
−
1
View file @
2cfe36e5
...
...
@@ -94,6 +94,7 @@ public:
T
getMissValue
()
const
;
double
getMissValueDouble
()
const
;
void
setMissValue
(
double
value
);
private:
Field
(
int
grid
,
size_t
gridsize
,
double
missval
,
size_t
size
);
...
...
@@ -177,6 +178,12 @@ inline double Field<T>::getMissValueDouble() const
return
missval
;
}
template
<
typename
T
>
inline
void
Field
<
T
>::
setMissValue
(
double
value
)
{
this
->
missval
=
static_cast
<
T
>
(
value
);
}
/************************************************
************************************************
******************** Field3D *******************
...
...
@@ -228,7 +235,8 @@ using _var_ = std::variant<FieldDouble, FieldFloat>;
class
Field_t
:
public
_var_
{
public:
// Overwrites of the std::variant<> constructors
constexpr
Field_t
()
noexcept
;
constexpr
Field_t
()
noexcept
:
_var_
()
{
}
Field_t
(
Field_t
&
other
)
:
_var_
(
other
)
{
}
...
...
@@ -281,6 +289,47 @@ public:
_var_
::
operator
=
(
std
::
move
(
t
));
return
*
this
;
}
void
resize
(
size_t
count
)
{
if
(
std
::
holds_alternative
<
FieldFloat
>
(
*
this
))
{
std
::
get
<
FieldFloat
>
(
*
this
).
resize
(
count
);
}
else
if
(
std
::
holds_alternative
<
FieldDouble
>
(
*
this
))
{
std
::
get
<
FieldDouble
>
(
*
this
).
resize
(
count
);
}
else
{
throw
std
::
runtime_error
(
"Not supported Type"
);
}
}
template
<
typename
U
>
void
resize
(
size_t
count
,
const
U
value
)
{
if
(
std
::
holds_alternative
<
FieldFloat
>
(
*
this
))
{
std
::
get
<
FieldFloat
>
(
*
this
).
resize
(
count
);
}
else
if
(
std
::
holds_alternative
<
FieldDouble
>
(
*
this
))
{
std
::
get
<
FieldDouble
>
(
*
this
).
resize
(
count
);
}
else
{
throw
std
::
runtime_error
(
"Not supported Type"
);
}
}
void
setMissValue
(
double
value
)
{
if
(
std
::
holds_alternative
<
FieldFloat
>
(
*
this
))
{
std
::
get
<
FieldFloat
>
(
*
this
).
setMissValue
(
value
);
}
else
if
(
std
::
holds_alternative
<
FieldDouble
>
(
*
this
))
{
std
::
get
<
FieldDouble
>
(
*
this
).
setMissValue
(
value
);
}
else
{
throw
std
::
runtime_error
(
"Not supported Type"
);
}
}
double
getMissValue
()
const
{
if
(
std
::
holds_alternative
<
FieldFloat
>
(
*
this
))
{
return
std
::
get
<
FieldFloat
>
(
*
this
).
getMissValue
();
}
else
if
(
std
::
holds_alternative
<
FieldDouble
>
(
*
this
))
{
return
std
::
get
<
FieldDouble
>
(
*
this
).
getMissValue
();
}
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