Skip to content

Commit

Permalink
Merge pull request GLVis#314 from GLVis/more-js-fixes
Browse files Browse the repository at this point in the history
Quadrature visualization support for glvis-js
  • Loading branch information
najlkin authored Sep 4, 2024
2 parents 3cdb2d6 + 2f34101 commit 7053ae2
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions lib/aux_js.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ namespace js

using namespace mfem;

// switch representation of the quadrature function
void SwitchQuadSolution();

//
// display a new stream
// field_type: 0 - scalar data, 1 - vector data, 2 - mesh only, (-1) - unknown
Expand Down Expand Up @@ -91,6 +94,11 @@ StreamState::FieldType display(const StreamState::FieldType field_type,
delete vs;
vs = nullptr;

if (stream_state.quad_f)
{
GetAppWindow()->setOnKeyDown('Q', SwitchQuadSolution);
}

double mesh_range = -1.0;
if (field_type == StreamState::FieldType::SCALAR
|| field_type == StreamState::FieldType::MESH)
Expand Down Expand Up @@ -140,14 +148,12 @@ StreamState::FieldType display(const StreamState::FieldType field_type,
if (stream_state.mesh->Dimension() == 3)
{
// Use the 'white' palette when visualizing a 3D volume mesh only
// vs->palette.SetIndex(4);
vs->palette.SetIndex(11);
vss->SetLightMatIdx(4);
}
else
{
// Use the 'bone' palette when visualizing a surface mesh only
// (the same as when visualizing a 2D mesh only)
vs->palette.SetIndex(4);
}
// Otherwise, the 'vivid' palette is used in 3D see vssolution3d.cpp
Expand Down Expand Up @@ -179,20 +185,22 @@ StreamState::FieldType display(const StreamState::FieldType field_type,
else
{
vs = new VisualizationSceneVector(*stream_state.mesh, stream_state.solu,
stream_state.solv);
stream_state.solv, stream_state.mesh_quad.get());
}
}
else if (stream_state.mesh->SpaceDimension() == 3)
{
if (stream_state.grid_f)
{
stream_state.ProjectVectorFEGridFunction();
vs = new VisualizationSceneVector3d(*stream_state.grid_f);
vs = new VisualizationSceneVector3d(*stream_state.grid_f,
stream_state.mesh_quad.get());
}
else
{
vs = new VisualizationSceneVector3d(*stream_state.mesh, stream_state.solu,
stream_state.solv, stream_state.solw);
stream_state.solv, stream_state.solw,
stream_state.mesh_quad.get());
}
}
}
Expand Down Expand Up @@ -330,13 +338,6 @@ int updateStream(std::string stream)
std::string data_type;
ss >> data_type;

if (data_type != "solution")
{
std::cerr << "unsupported data type '" << data_type << "' for stream update" <<
std::endl;
return 1;
}

StreamState new_state;
new_state.ReadStream(ss, data_type);

Expand Down Expand Up @@ -469,6 +470,14 @@ em::val getScreenBuffer(bool flip_y=false)
screen_state->data()));
}

void SwitchQuadSolution()
{
int iqs = ((int)stream_state.GetQuadSolution()+1)
% ((int)StreamState::QuadSolution::MAX);
stream_state.SwitchQuadSolution((StreamState::QuadSolution)iqs, vs);
SendExposeEvent();
}

#ifdef GLVIS_USE_LIBPNG
em::val getPNGByteArray()
{
Expand Down

0 comments on commit 7053ae2

Please sign in to comment.