Skip to content
Snippets Groups Projects
Commit dbf808fe authored by Lars Bilke's avatar Lars Bilke Committed by Lars Bilke
Browse files

[insitu] WIP implementation of insitu vis.

parent d43b5d7b
No related branches found
No related tags found
No related merge requests found
...@@ -16,6 +16,10 @@ if(OGS_USE_PETSC) ...@@ -16,6 +16,10 @@ if(OGS_USE_PETSC)
target_link_libraries(ogs ${PETSC_LIBRARIES}) target_link_libraries(ogs ${PETSC_LIBRARIES})
endif() endif()
if(OGS_INSITU)
target_link_libraries(ogs InSituLib)
endif()
#################### ####################
### Tests ########## ### Tests ##########
#################### ####################
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "Applications/ApplicationsLib/LinearSolverLibrarySetup.h" #include "Applications/ApplicationsLib/LinearSolverLibrarySetup.h"
#include "Applications/ApplicationsLib/LogogSetup.h" #include "Applications/ApplicationsLib/LogogSetup.h"
#include "Applications/ApplicationsLib/ProjectData.h" #include "Applications/ApplicationsLib/ProjectData.h"
#include "Applications/InSituLib/Adaptor.h"
#include "ProcessLib/UncoupledProcessesTimeLoop.h" #include "ProcessLib/UncoupledProcessesTimeLoop.h"
#include "NumLib/NumericsConfig.h" #include "NumLib/NumericsConfig.h"
...@@ -117,11 +118,11 @@ int main(int argc, char *argv[]) ...@@ -117,11 +118,11 @@ int main(int argc, char *argv[])
BaseLib::extractPath(project_arg.getValue()), BaseLib::extractPath(project_arg.getValue()),
outdir_arg.getValue()); outdir_arg.getValue());
// Check intermediately that config parsing went fine. #ifdef USE_INSITU
project_config.checkAndInvalidate(); INFO("Initialize insitu scripts.");
BaseLib::ConfigTree::assertNoSwallowedErrors(); if (auto t = project_config->getConfigSubtreeOptional("insitu"))
InSituLib::Initialize(t->getConfigSubtree("scripts"), BaseLib::extractPath(project_arg.getValue()));
BaseLib::ConfigTree::assertNoSwallowedErrors(); #endif
INFO("Initialize processes."); INFO("Initialize processes.");
for (auto& p : project.getProcesses()) for (auto& p : project.getProcesses())
...@@ -129,12 +130,23 @@ int main(int argc, char *argv[]) ...@@ -129,12 +130,23 @@ int main(int argc, char *argv[])
p.second->initialize(); p.second->initialize();
} }
// Check intermediately that config parsing went fine.
project_config.checkAndInvalidate();
BaseLib::ConfigTree::assertNoSwallowedErrors();
BaseLib::ConfigTree::assertNoSwallowedErrors();
BaseLib::ConfigTree::assertNoSwallowedErrors(); BaseLib::ConfigTree::assertNoSwallowedErrors();
INFO("Solve processes."); INFO("Solve processes.");
auto& time_loop = project.getTimeLoop(); auto& time_loop = project.getTimeLoop();
solver_succeeded = time_loop.loop(); solver_succeeded = time_loop.loop();
#ifdef USE_INSITU
if (project_config->getConfigSubtreeOptional("insitu"))
InSituLib::Finalize();
#endif
} // This nested scope ensures that everything that could possibly } // This nested scope ensures that everything that could possibly
// possess a ConfigTree is destructed before the final check below is // possess a ConfigTree is destructed before the final check below is
// done. // done.
......
...@@ -17,3 +17,7 @@ endif() # OGS_BUILD_GUI ...@@ -17,3 +17,7 @@ endif() # OGS_BUILD_GUI
if(OGS_BUILD_CLI) if(OGS_BUILD_CLI)
add_subdirectory(CLI) add_subdirectory(CLI)
endif() # OGS_BUILD_CLI endif() # OGS_BUILD_CLI
if(OGS_INSITU)
add_subdirectory(InSituLib)
endif()
/**
* \copyright
* Copyright (c) 2012-2017, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#include "Adaptor.h"
#include <vtkCPDataDescription.h>
#include <vtkCPInputDataDescription.h>
#include <vtkCPProcessor.h>
#include <vtkCPPythonScriptPipeline.h>
#include <vtkNew.h>
#include <vtkUnstructuredGrid.h>
#include "MeshLib/Mesh.h"
#include "MeshLib/Vtk/VtkMappedMeshSource.h"
namespace InSituLib
{
vtkCPProcessor* Processor = NULL;
void Initialize(BaseLib::ConfigTree const & scripts_config, std::string const & path)
{
if (Processor == NULL)
{
Processor = vtkCPProcessor::New();
Processor->Initialize();
}
else
{
Processor->RemoveAllPipelines();
}
for (auto script_config : scripts_config.getConfigSubtreeList("script"))
{
std::stringstream ss;
ss << path << script_config.getConfigParameter<std::string>("name");
vtkNew<vtkCPPythonScriptPipeline> pipeline;
pipeline->Initialize(ss.str().c_str());
Processor->AddPipeline(pipeline.GetPointer());
}
}
void Finalize()
{
if (Processor)
{
Processor->Delete();
Processor = NULL;
}
}
void CoProcess(MeshLib::Mesh const& mesh, double const time,
unsigned int const timeStep, bool const lastTimeStep)
{
vtkNew<vtkCPDataDescription> dataDescription;
dataDescription->AddInput("input");
dataDescription->SetTimeData(time, timeStep);
if (lastTimeStep == true)
{
// assume that we want to all the pipelines to execute if it
// is the last time step.
dataDescription->ForceOutputOn();
}
if (Processor->RequestDataDescription(dataDescription.GetPointer()) != 0)
{
INFO("Start InSitu process.");
vtkNew<MeshLib::VtkMappedMeshSource> vtkSource;
vtkSource->SetMesh(&mesh);
vtkSource->Update();
dataDescription->GetInputDescriptionByName("input")->SetGrid(vtkSource->GetOutput());
Processor->CoProcess(dataDescription.GetPointer());
INFO("End InSitu process.");
}
}
} // namespace
/**
* \copyright
* Copyright (c) 2012-2017, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#pragma once
#include "BaseLib/ConfigTree.h"
namespace MeshLib {
class Mesh;
}
namespace InSituLib {
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);
}
# Source files
GET_SOURCE_FILES(SOURCES)
# Library
add_library(InSituLib ${SOURCES})
# target_link_libraries(InSituLib )
...@@ -213,6 +213,7 @@ include(VtkModules) ...@@ -213,6 +213,7 @@ include(VtkModules)
if(OGS_INSITU) if(OGS_INSITU)
include(ExternalProjectCatalyst) include(ExternalProjectCatalyst)
include("${PARAVIEW_USE_FILE}") include("${PARAVIEW_USE_FILE}")
add_definitions(-DUSE_INSITU)
else() else()
include(ExternalProjectVtk) include(ExternalProjectVtk)
endif() endif()
......
...@@ -70,3 +70,6 @@ endif() ...@@ -70,3 +70,6 @@ endif()
if(TARGET Boost) if(TARGET Boost)
add_dependencies(ProcessLib Boost) add_dependencies(ProcessLib Boost)
endif() endif()
if(OGS_INSITU)
target_link_libraries(ProcessLib InSituLib)
endif()
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "BaseLib/FileTools.h" #include "BaseLib/FileTools.h"
#include "BaseLib/RunTime.h" #include "BaseLib/RunTime.h"
#include "Applications/InSituLib/Adaptor.h"
namespace namespace
{ {
...@@ -124,6 +125,11 @@ void Output::doOutputAlways(Process const& process, ...@@ -124,6 +125,11 @@ void Output::doOutputAlways(Process const& process,
INFO("[time] Output of timestep %d took %g s.", timestep, INFO("[time] Output of timestep %d took %g s.", timestep,
time_output.elapsed()); time_output.elapsed());
#ifdef USE_INSITU
// TODO: get number of timesteps
InSituLib::CoProcess(process.getMesh(), t, timestep, false);
#endif
} }
void Output::doOutput(Process const& process, void Output::doOutput(Process const& process,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment