https://mooseframework.inl.gov
Loading...
Searching...
No Matches
thermal_hydraulics
src
outputs
ParaviewComponentAnnotationMap.C
Go to the documentation of this file.
1
//* This file is part of the MOOSE framework
2
//* https://mooseframework.inl.gov
3
//*
4
//* All rights reserved, see COPYRIGHT for full restrictions
5
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6
//*
7
//* Licensed under LGPL 2.1, please see LICENSE for details
8
//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10
#include "
ParaviewComponentAnnotationMap.h
"
11
12
#include "nlohmann/json.h"
13
#include "
LockFile.h
"
14
#include "
JsonIO.h
"
15
#include "
THMProblem.h
"
16
#include "
Component.h
"
17
#include <fstream>
18
19
registerMooseObject
(
"ThermalHydraulicsApp"
,
ParaviewComponentAnnotationMap
);
20
22
static
const
std::vector<Real>
kaams_colors
= {1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0,
23
0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0,
24
0.0, 1.0, 1.0, 0.63, 0.63, 1.0, 0.67, 0.5, 0.33,
25
1.0, 0.5, 0.75, 0.53, 0.35, 0.7, 1.0, 0.75, 0.5};
26
27
InputParameters
28
ParaviewComponentAnnotationMap::validParams
()
29
{
30
InputParameters
params =
FileOutput::validParams
();
31
ExecFlagEnum
execute_options =
MooseUtils::getDefaultExecFlagEnum
();
32
execute_options = {
EXEC_INITIAL
};
33
params.
set
<
ExecFlagEnum
>(
"execute_on"
) = execute_options;
34
return
params;
35
}
36
37
ParaviewComponentAnnotationMap::ParaviewComponentAnnotationMap
(
const
InputParameters
& parameters)
38
:
FileOutput
(parameters)
39
{
40
THMProblem
* thm_problem =
dynamic_cast<
THMProblem
*
>
(
_problem_ptr
);
41
if
(!thm_problem)
42
mooseError
(
name
(),
43
": ParaviewComponentAnnotationMap can only be used with THM-based simulation."
);
44
}
45
46
void
47
ParaviewComponentAnnotationMap::output
()
48
{
49
if
(
processor_id
() == 0)
50
{
51
THMProblem
* thm_problem =
dynamic_cast<
THMProblem
*
>
(
_problem_ptr
);
52
const
std::vector<std::shared_ptr<Component>> & comps = thm_problem->
getComponents
();
53
54
std::vector<Real> clrs;
55
unsigned
int
clr_idx = 0;
56
57
std::vector<std::string> anns;
58
for
(
auto
& comp : comps)
59
{
60
const
auto
& subdomains = comp->getSubdomainNames();
61
for
(
auto
& sn : subdomains)
62
{
63
SubdomainID
sid =
_mesh_ptr
->
getSubdomainID
(sn);
64
65
anns.push_back(
Moose::stringify
(sid));
66
anns.push_back(sn);
67
68
clrs.push_back(
kaams_colors
[clr_idx++]);
69
clrs.push_back(
kaams_colors
[clr_idx++]);
70
clrs.push_back(
kaams_colors
[clr_idx++]);
71
// 12 colors with RGB values
72
clr_idx = clr_idx % (12 * 3);
73
}
74
}
75
76
nlohmann::json json;
77
json[0][
"Annotations"
] = anns;
78
json[0][
"IndexedColors"
] = clrs;
79
json[0][
"Name"
] =
_file_base
;
80
81
std::ofstream out(
filename
().c_str());
82
out << std::setw(4) << json << std::endl;
83
}
84
}
85
86
std::string
87
ParaviewComponentAnnotationMap::filename
()
88
{
89
return
_file_base
+
".json"
;
90
}
Component.h
JsonIO.h
LockFile.h
EXEC_INITIAL
const ExecFlagType EXEC_INITIAL
kaams_colors
static const std::vector< Real > kaams_colors
KAAMS color profile from paraview.
Definition
ParaviewComponentAnnotationMap.C:22
registerMooseObject
registerMooseObject("ThermalHydraulicsApp", ParaviewComponentAnnotationMap)
ParaviewComponentAnnotationMap.h
THMProblem.h
ExecFlagEnum
FileOutput
FileOutput::validParams
static InputParameters validParams()
FileOutput::_file_base
std::string _file_base
InputParameters::set
T & set(const std::string &name, bool quiet_mode=false)
FileOutput::name
const std::string & name() const
FileOutput::mooseError
void mooseError(Args &&... args) const
MooseMesh::getSubdomainID
SubdomainID getSubdomainID(const SubdomainName &subdomain_name) const
FileOutput::_problem_ptr
FEProblemBase * _problem_ptr
FileOutput::_mesh_ptr
MooseMesh * _mesh_ptr
ParaviewComponentAnnotationMap
Output annotation map for paraview.
Definition
ParaviewComponentAnnotationMap.h:23
ParaviewComponentAnnotationMap::validParams
static InputParameters validParams()
Definition
ParaviewComponentAnnotationMap.C:28
ParaviewComponentAnnotationMap::filename
virtual std::string filename()
Definition
ParaviewComponentAnnotationMap.C:87
ParaviewComponentAnnotationMap::ParaviewComponentAnnotationMap
ParaviewComponentAnnotationMap(const InputParameters ¶meters)
Definition
ParaviewComponentAnnotationMap.C:37
ParaviewComponentAnnotationMap::output
virtual void output()
Definition
ParaviewComponentAnnotationMap.C:47
Simulation::getComponents
const std::vector< std::shared_ptr< Component > > & getComponents() const
Return list of components available in the simulation.
Definition
Simulation.h:117
THMProblem
Specialization of FEProblem to run with component subsystem.
Definition
THMProblem.h:19
libMesh::ParallelObject::processor_id
processor_id_type processor_id() const
libMesh::TestClass
MooseUtils::getDefaultExecFlagEnum
ExecFlagEnum getDefaultExecFlagEnum()
Moose::stringify
std::string stringify(const T &t)
InputParameters
Generated on Fri Aug 21 2026 13:42:00 for https://mooseframework.inl.gov by
1.9.8