Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
dumux-repositories
dumux
Commits
f29cbeca
Commit
f29cbeca
authored
Jun 20, 2021
by
Martin Schneider
Browse files
[metadata] Outsource functions
parent
958d3ef5
Changes
1
Hide whitespace changes
Inline
Side-by-side
dumux/common/metadata.hh
View file @
f29cbeca
...
...
@@ -82,62 +82,26 @@ class Metadata {
using
JsonTree
=
nlohmann
::
json
;
public:
template
<
class
TypeTag
,
DiffMethod
diffmethod
,
bool
isImplicit
>
static
void
collectMetaData
(
const
FVAssembler
<
TypeTag
,
diffmethod
,
isImplicit
>&
a
,
bool
hideTemplates
=
true
)
{
auto
&
obj
=
getTree
()[
"Assembler"
];
obj
[
"Type"
]
=
className_
(
a
,
hideTemplates
);
obj
[
"Stationary"
]
=
a
.
isStationaryProblem
()
?
"true"
:
"false"
;
}
template
<
class
GridGeometry
>
static
auto
collectMetaData
(
const
GridGeometry
&
gg
,
bool
hideTemplates
=
true
)
->
typename
std
::
enable_if_t
<
decltype
(
isValid
(
Detail
::
isGridGeometry
())(
gg
))
::
value
,
void
>
{
auto
&
obj
=
getTree
()[
"GridGeometry"
];
obj
[
"Type"
]
=
className_
(
gg
,
hideTemplates
);
obj
[
"GridView"
][
"Type"
]
=
className_
(
gg
.
gridView
(),
hideTemplates
);
obj
[
"IsPeriodic"
]
=
gg
.
isPeriodic
()
?
"true"
:
"false"
;
obj
[
"DiscretisationMethod"
]
=
discretizationMethodToString
(
GridGeometry
::
discMethod
);
obj
[
"MaxElementStencilSize"
]
=
GridGeometry
::
maxElementStencilSize
;
obj
[
"NumScvs"
]
=
gg
.
numScv
();
obj
[
"NumScvfs"
]
=
gg
.
numScvf
();
obj
[
"SumBoundaryScvfs"
]
=
gg
.
numBoundaryScvf
();
obj
[
"NumDofs"
]
=
gg
.
numDofs
();
}
template
<
class
GridVariables
>
static
auto
collectMetaData
(
const
GridVariables
&
gv
,
bool
hideTemplates
=
true
)
->
typename
std
::
enable_if_t
<
decltype
(
isValid
(
Detail
::
isGridVariables
())(
gv
))
::
value
,
void
>
{
auto
&
obj
=
getTree
()[
"GridVariables"
];
obj
[
"Type"
]
=
className_
(
gv
,
hideTemplates
);
}
//! prints json tree
static
void
print
()
{
std
::
cout
<<
getTree
().
dump
(
4
)
<<
std
::
endl
;
}
/*!
* \brief Get the json tree
*/
static
JsonTree
&
getTree
()
JsonTree
&
getTree
()
{
static
JsonTree
parser_
;
return
parser_
;
return
tree_
;
}
const
JsonTree
&
getTree
()
const
{
return
tree_
;
}
private:
template
<
class
T
>
static
std
::
string
className
_
(
const
T
&
c
,
bool
hideTemplates
)
static
std
::
string
className
(
const
T
&
c
,
bool
hideTemplates
)
{
return
hideTemplates
?
hideTemplateArguments
_
(
Dune
::
className
(
c
))
:
Dune
::
className
(
c
);
return
hideTemplates
?
hideTemplateArguments
(
Dune
::
className
(
c
))
:
Dune
::
className
(
c
);
}
static
std
::
string
hideTemplateArguments
_
(
std
::
string
&&
s
)
static
std
::
string
hideTemplateArguments
(
std
::
string
&&
s
)
{
std
::
size_t
first
=
s
.
find
(
"<"
);
std
::
size_t
last
=
s
.
find_last_of
(
">"
);
...
...
@@ -150,9 +114,49 @@ private:
return
std
::
move
(
s
);
}
private:
JsonTree
tree_
;
};
//! prints json tree
template
<
class
Collector
>
void
print
(
const
Collector
&
collector
)
{
std
::
cout
<<
collector
.
getTree
().
dump
(
4
)
<<
std
::
endl
;
}
template
<
class
Collector
,
class
TypeTag
,
DiffMethod
diffmethod
,
bool
isImplicit
>
void
collectMetaData
(
Collector
&
collector
,
const
FVAssembler
<
TypeTag
,
diffmethod
,
isImplicit
>&
a
,
bool
hideTemplates
=
true
)
{
auto
&
obj
=
collector
.
getTree
()[
"Assembler"
];
obj
[
"Type"
]
=
Metadata
::
className
(
a
,
hideTemplates
);
obj
[
"Stationary"
]
=
a
.
isStationaryProblem
()
?
"true"
:
"false"
;
}
template
<
class
Collector
,
class
GridGeometry
>
auto
collectMetaData
(
Collector
&
collector
,
const
GridGeometry
&
gg
,
bool
hideTemplates
=
true
)
->
typename
std
::
enable_if_t
<
decltype
(
isValid
(
Detail
::
isGridGeometry
())(
gg
))
::
value
,
void
>
{
auto
&
obj
=
collector
.
getTree
()[
"GridGeometry"
];
obj
[
"Type"
]
=
Metadata
::
className
(
gg
,
hideTemplates
);
obj
[
"GridView"
][
"Type"
]
=
Metadata
::
className
(
gg
.
gridView
(),
hideTemplates
);
obj
[
"IsPeriodic"
]
=
gg
.
isPeriodic
()
?
"true"
:
"false"
;
obj
[
"DiscretisationMethod"
]
=
discretizationMethodToString
(
GridGeometry
::
discMethod
);
obj
[
"MaxElementStencilSize"
]
=
GridGeometry
::
maxElementStencilSize
;
obj
[
"NumScvs"
]
=
gg
.
numScv
();
obj
[
"NumScvfs"
]
=
gg
.
numScvf
();
obj
[
"SumBoundaryScvfs"
]
=
gg
.
numBoundaryScvf
();
obj
[
"NumDofs"
]
=
gg
.
numDofs
();
}
template
<
class
Collector
,
class
GridVariables
>
auto
collectMetaData
(
Collector
&
collector
,
const
GridVariables
&
gv
,
bool
hideTemplates
=
true
)
->
typename
std
::
enable_if_t
<
decltype
(
isValid
(
Detail
::
isGridVariables
())(
gv
))
::
value
,
void
>
{
auto
&
obj
=
collector
.
getTree
()[
"GridVariables"
];
obj
[
"Type"
]
=
Metadata
::
className
(
gv
,
hideTemplates
);
}
}
// end namespace Dumux
#endif
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