Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions cli/view_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,30 @@
#
# -----------------------------------------------------------------------------

import os, sys, shutil
import os
import subprocess as sp
import sys

from print_command import Print
from build_command import BuildCommand


## The BioDynaMo CLI command to execute the unit-tests created by default with
## the simulation template. Note that we ignore the configuration in bdm.json.
def ViewCommand(file_id=None):
Print.success("<bdm view> Opening previous simulation results ...")
# 1. Check if paraview is installed and if not, return
bdmsys = os.environ.get("BDMSYS")
if bdmsys is None:
Print.error("<bdm view> BDMSYS is not set.")
# 1. Check if ParaView is available on PATH.
try:
pv_found = sp.run(
["paraview", "--version"],
stdout=sp.DEVNULL,
stderr=sp.DEVNULL,
check=False,
)
except FileNotFoundError:
Print.error("<bdm view> ParaView not found.")
sys.exit(1)
paraview_executable = os.path.join(
bdmsys, "third_party/paraview/bin/paraview"
)
pv_found = sp.run("{} --version".format(paraview_executable), shell=True)
if pv_found.returncode != 0:
Print.error("<bdm view> ParaView not found.")
Print.error("<bdm view> ParaView could not be started.")
sys.exit(1)

# 2. attempt to change into project director if we are in build
Expand Down Expand Up @@ -83,9 +86,7 @@ def ViewCommand(file_id=None):
os.chdir("build")

# 9. Open the latest pvsm file
visualize = sp.run(
"{} --state={}".format(paraview_executable, pvsm_file), shell=True
)
visualize = sp.run(["paraview", "--state={}".format(pvsm_file)])
if visualize.returncode != 0:
Print.warning(
"<bdm view> Visualization terminated with return code {}.".format(
Expand Down
4 changes: 3 additions & 1 deletion paraview_plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
option(BUILD_SHARED_LIBS "Build shared libraries" ON)

find_package(MPI REQUIRED)
find_package(ParaView REQUIRED)
find_package(ParaView REQUIRED COMPONENTS
RemotingServerManager
VTKExtensionsFiltersGeneral)

set("_paraview_plugin_default_${CMAKE_PROJECT_NAME}" ON)
paraview_plugin_scan(
Expand Down
1 change: 1 addition & 0 deletions paraview_plugin/Plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
paraview_add_plugin(BDMGlyphFilter
VERSION "1.0"
XML_DOCUMENTATION OFF
REQUIRED_ON_SERVER
REQUIRED_ON_CLIENT
MODULES BDM
Expand Down
30 changes: 3 additions & 27 deletions src/core/visualization/paraview/adaptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
#include "core/visualization/paraview/vtk_agents.h"
#include "core/visualization/paraview/vtk_diffusion_grid.h"

#ifndef __ROOTCLING__

#include <vtkCPDataDescription.h>
#include <vtkCPInputDataDescription.h>
#include <vtkCPProcessor.h>
Expand Down Expand Up @@ -214,7 +212,8 @@ void ParaviewAdaptor::CreateVtkObjects() {
void ParaviewAdaptor::BuildAgentsVTKStructures() {
auto* rm = Simulation::GetActive()->GetResourceManager();
for (auto& pair : impl_->vtk_agents_) {
const auto& agents = rm->GetTypeIndex()->GetType(pair.second->GetTClass());
const auto& agents =
rm->GetTypeIndex()->GetType(pair.second->GetTypeName());
pair.second->Update(&agents);
}
}
Expand Down Expand Up @@ -251,10 +250,9 @@ void ParaviewAdaptor::WriteSimulationInfoJsonFile() {
void ParaviewAdaptor::GenerateParaviewState() {
auto* sim = Simulation::GetActive();
std::stringstream python_cmd;
std::string pv_dir = std::getenv("ParaView_DIR");
std::string bdmsys = std::getenv("BDMSYS");

python_cmd << pv_dir << "/bin/pvbatch " << bdmsys
python_cmd << "pvbatch " << bdmsys
<< "/include/core/visualization/paraview/generate_pv_state.py "
<< sim->GetOutputDir() << "/" << kSimulationInfoJson;
int ret_code = system(python_cmd.str().c_str());
Expand Down Expand Up @@ -298,25 +296,3 @@ std::string ParaviewAdaptor::BuildPythonScriptString(
}

} // namespace bdm

#else

namespace bdm {

ParaviewAdaptor::ParaviewAdaptor() {}

void ParaviewAdaptor::Visualize() {}

void ParaviewAdaptor::InsituVisualization() {}

void ParaviewAdaptor::ExportVisualization() {}

void ParaviewAdaptor::WriteToFile() {}

void ParaviewAdaptor::GenerateParaviewState() {}

std::string ParaviewAdaptor::BuildPythonScriptString(
const std::string& python_script) {}
} // namespace bdm

#endif
10 changes: 4 additions & 6 deletions src/core/visualization/paraview/adaptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
namespace bdm {

/// The class that bridges the simulation code with ParaView.
class ParaviewAdaptor : private VisualizationAdaptor {
class ParaviewAdaptor : public VisualizationAdaptor {
public:
/// Initializes Catalyst with the predefined pipeline and allocates memory
/// for the VTK grid structures
Expand All @@ -50,11 +50,11 @@ class ParaviewAdaptor : private VisualizationAdaptor {
struct ParaviewImpl;

private:
std::unique_ptr<ParaviewImpl> impl_; //!
static std::atomic<uint64_t> counter_; //!
std::unique_ptr<ParaviewImpl> impl_;
static std::atomic<uint64_t> counter_;

/// only needed for insitu visualization
bool initialized_ = false; //!
bool initialized_ = false;
bool simulation_info_json_generated_ = false;

friend class ParaviewAdaptorTest_GenerateSimulationInfoJson_Test;
Expand Down Expand Up @@ -96,8 +96,6 @@ class ParaviewAdaptor : private VisualizationAdaptor {
/// Combine user-defined python script with biodynamo default python
/// insitu pipeline.
static std::string BuildPythonScriptString(const std::string& python_script);

ClassDefNV(ParaviewAdaptor, 1);
};

} // namespace bdm
Expand Down
2 changes: 0 additions & 2 deletions src/core/visualization/paraview/helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
#include "core/visualization/paraview/vtk_agents.h"
#include "core/visualization/paraview/vtk_diffusion_grid.h"

class TClass;

namespace bdm {

static constexpr char const* kSimulationInfoJson = "simulation_info.json";
Expand Down
144 changes: 0 additions & 144 deletions src/core/visualization/paraview/jit_helper.h

This file was deleted.

Loading
Loading