OGS
InSituLib Namespace Reference

Functions

void Initialize (BaseLib::ConfigTree const &scripts_config, std::string const &path)
 
void Finalize ()
 
void CoProcess (MeshLib::Mesh const &mesh, double const time, unsigned int const timeStep, bool const lastTimeStep, std::string output_directory)
 

Variables

vtkCPProcessor * Processor = nullptr
 

Function Documentation

◆ CoProcess()

void InSituLib::CoProcess ( MeshLib::Mesh const & mesh,
double const time,
unsigned int const timeStep,
bool const lastTimeStep,
std::string output_directory )

Definition at line 70 of file Adaptor.cpp.

73{
74 if (Processor == nullptr)
75 return;
76
77 vtkNew<vtkCPDataDescription> dataDescription;
78 dataDescription->AddInput("input");
79 dataDescription->SetTimeData(time, timeStep);
80 if (lastTimeStep == true)
81 {
82 // assume that we want to all the pipelines to execute if it
83 // is the last time step.
84 dataDescription->ForceOutputOn();
85 }
86 if (Processor->RequestDataDescription(dataDescription.GetPointer()) != 0)
87 {
88 INFO("Start InSitu process: timestep #{:d} (t={:g}, last={:d})",
89 timeStep, time, lastTimeStep);
90 vtkNew<MeshLib::VtkMappedMeshSource> vtkSource;
91 vtkSource->SetMesh(&mesh);
92 vtkSource->Update();
93 dataDescription->GetInputDescriptionByName("input")->SetGrid(
94 vtkSource->GetOutput());
95 auto const cwd = std::filesystem::current_path();
96 std::filesystem::current_path(std::move(output_directory));
97 Processor->CoProcess(dataDescription.GetPointer());
98 std::filesystem::current_path(cwd);
99 INFO("End InSitu process.");
100 }
101}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:35

References INFO(), and Processor.

Referenced by ProcessLib::Output::doOutput(), and ProcessLib::Output::doOutputLastTimestep().

◆ Finalize()

void InSituLib::Finalize ( )

Definition at line 62 of file Adaptor.cpp.

63{
64 if (Processor)
65 {
66 Processor->Delete();
67 Processor = nullptr;
68 }
69}
vtkCPProcessor * Processor
Definition Adaptor.cpp:28

References Processor.

Referenced by Simulation::~Simulation().

◆ Initialize()

void InSituLib::Initialize ( BaseLib::ConfigTree const & scripts_config,
std::string const & path )
Input File Parameter
prj__insitu__scripts__script
Input File Parameter
prj__insitu__scripts__script__name

Definition at line 30 of file Adaptor.cpp.

32{
33 if (Processor == nullptr)
34 {
35 Processor = vtkCPProcessor::New();
36 Processor->Initialize();
37 }
38 else
39 {
40 Processor->RemoveAllPipelines();
41 }
43 for (auto script_config : scripts_config.getConfigSubtreeList("script"))
44 {
45 auto scriptPath = std::filesystem::path(
47 script_config.getConfigParameter<std::string>("name"));
48 if (scriptPath.is_relative())
49 {
50 scriptPath = std::filesystem::path(path) / scriptPath;
51 }
52 if (!std::filesystem::exists(scriptPath))
53 {
54 ERR("In-situ script {:s} does not exist!", scriptPath.string());
55 }
56 INFO("Initializing in-situ script: {:s}", scriptPath.string());
57 vtkNew<vtkCPPythonScriptPipeline> pipeline;
58 pipeline->Initialize(scriptPath.c_str());
59 Processor->AddPipeline(pipeline.GetPointer());
60 }
61}
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:45

References ERR(), BaseLib::ConfigTree::getConfigSubtreeList(), INFO(), and Processor.

Referenced by Simulation::initializeDataStructures().

Variable Documentation

◆ Processor

vtkCPProcessor* InSituLib::Processor = nullptr

Definition at line 28 of file Adaptor.cpp.

Referenced by CoProcess(), Finalize(), and Initialize().