Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
ecd83fa
Setup PrepareDofNumbering2
camierjs May 27, 2025
92f9401
Without GetNodes to use GetRefinedValues
camierjs May 28, 2025
2209f12
Simplify
camierjs May 28, 2025
f695d40
Mixed mesh support & cleanup
camierjs May 28, 2025
3c06674
Avoid using namespace in headers
camierjs May 28, 2025
1e3b49e
Remove settings file
camierjs May 28, 2025
92bf967
Cleanup
camierjs May 28, 2025
c6b5669
Add debug includes and update gitignore
camierjs May 28, 2025
3e41dd9
Add missing std headers
camierjs May 28, 2025
f5d510f
Add missing std headers
camierjs May 28, 2025
1d682f8
- Fix VisualizationSceneSolution solution data w/ Flat shading
camierjs May 31, 2025
ffdf27c
Fix drawnums value verification
camierjs May 31, 2025
6ce73a7
Add numbering option output
camierjs May 31, 2025
91955f5
Revert makefile
camierjs May 31, 2025
18c1c1a
Update README file
camierjs May 31, 2025
f13cd31
Update CHANGELOG
camierjs May 31, 2025
28394d2
Fix VisualizationSceneVector sol delete
camierjs May 31, 2025
471b9be
Add edges and DOFs numbering in vsvector
camierjs May 31, 2025
6159085
Fix flat fes vdim
camierjs May 31, 2025
baf1839
Filter out unsupported basis types
camierjs Jun 2, 2025
b3a18c7
Insert adjusted vdofs
camierjs Jun 2, 2025
94cd9aa
Remove using namespace in render_core header
camierjs Jun 2, 2025
b28c2a9
Address review comments
camierjs Jun 3, 2025
5bb2e45
Finer filtering of DOFs numbering shadings
camierjs Jun 3, 2025
07e2e50
makefile spaces
camierjs Jun 3, 2025
bc07040
Use range type for basis filtering
camierjs Jun 3, 2025
6768b5e
Handle numbering for vector fe flat/smooth shading
camierjs Jun 3, 2025
bb8f229
Support L2 fec DOFs numbering w/ flat/smooth shading
camierjs Jun 3, 2025
562b149
Simplify PrepareDofNumbering
camierjs Jun 9, 2025
d464eb4
Allow not to shrink in GetRefinedValues
camierjs Jun 9, 2025
7685bc9
Fix numbering attr show for elems, vertices and edges
camierjs Jun 9, 2025
ef957af
Merge branch 'fix-data-reset' into dofs_numbering
camierjs Jun 9, 2025
3f80e0f
Revert changes for #343
camierjs Jun 9, 2025
4870bd8
Init local numberings
camierjs Jun 11, 2025
7e7efcb
SetDataOffsets after SetGridFunction
camierjs Jun 11, 2025
e799121
Use DataState::Offsets type
camierjs Jun 11, 2025
e218fce
Fix dofs PrepareDofNumbering
camierjs Jun 11, 2025
3d14338
Simplify
camierjs Jun 11, 2025
fcd8517
Simplify Prepare Numberings
camierjs Jun 11, 2025
854b715
Detect high-dpi display only if wndUseHiDPI
camierjs Jun 11, 2025
eb87b19
Merge branch 'master' into dofs_numbering_local
camierjs Jun 17, 2025
5901729
Add ex6-dofs-numbering
camierjs Jun 17, 2025
6f3baaf
Use MFEM_VERIFY instead of assert within GLVIS_DEBUG
camierjs Jun 17, 2025
74ed130
Try using dofs_numbering_tests_data
camierjs Jun 17, 2025
b62dfc0
Revert submodule branch
camierjs Jun 17, 2025
1d61739
Update Subproject data
camierjs Jun 17, 2025
d85aa12
Update data
camierjs Jun 17, 2025
29fd11a
Global/local parallel numbering with Alt-n
camierjs Jul 1, 2025
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
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,12 @@ compile_commands.json
# OS-specific: Mac
*.dSYM
.DS_Store

# Typical build directory
/build/

# Visual Studio Code
/.vscode/

# CMake user configuration files
user.cmake
7 changes: 7 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
https://glvis.org


Version 4.5 (development)
=========================

- Implemented DOF numbering, pressing the `n` or `N` key in 2D mode cycles through:
None → Elements → Edges → Vertices → DOFs. Parallel numbering is now by default
'local' to each rank; 'global' vs. 'local' numbering can be toggled with 'Alt+n'.

Version 4.4 released on May 1, 2025
===================================

Expand Down
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# introduced.
cmake_minimum_required(VERSION 3.10)


set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
Expand All @@ -24,6 +25,16 @@ endif ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")

project(glvis NONE)

# Load user settings
set(USER_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/user.cmake" CACHE PATH
"User configuration file. This file is not part of the GLVis source code and
is not distributed with GLVis. It can be used to set user-specific options,
such as paths to external libraries, compiler flags, etc.")
include("${USER_CONFIG}" OPTIONAL RESULT_VARIABLE USER_CONFIG_LOADED)
if (USER_CONFIG_LOADED)
message(STATUS "USER_CONFIG = ${USER_CONFIG} (LOADED)")
endif()

# Import MFEM. The following variables can be used to help CMake find MFEM:
# * MFEM_DIR - absolute path to the MFEM build or install prefix.
# * mfem_DIR - absolute path to where MFEMConfig.cmake is.
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,10 @@ Key commands
- <kbd>Ctrl</kbd> + <kbd>o</kbd> – Toggle an element ordering curve
- <kbd>n</kbd> / <kbd>N</kbd> – Cycle through numberings. The options are:
- none
- show element numbering
- show edge numbering
- show vertex numbering
- show elements numbering
- show edges numbering
- show vertices numbering
- show DOFs numbering
- <kbd>`</kbd> – Toggle a ruler, with initial origin at the center of the bounding box. The origin can be later moved with <kbd>~</kbd>. The options are:
- none
- coordinate axes lines
Expand Down
9 changes: 7 additions & 2 deletions glvis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
#include <cstdio>
#include <cstring>
#include <ctime>
#include <vector>
#include <memory>
#include <thread>
#include <utility>

// SDL may redefine main() as SDL_main() ostensibly to ease portability.
// (WinMain() instead of main() is used as the entry point in a non-console
Expand All @@ -31,8 +35,7 @@
#define SDL_MAIN_HANDLED
#endif

#include "mfem.hpp"
#include "lib/palettes.hpp"
#include <mfem.hpp>
#include "lib/visual.hpp"
#include "lib/stream_reader.hpp"
#include "lib/file_reader.hpp"
Expand Down Expand Up @@ -171,6 +174,7 @@ bool GLVisInitVis(StreamCollection input_streams)
// the 'jet-like' palette is used in 2D, see vssolution.cpp).
vs->palette.SetIndex(4);
}
vs->SetDataOffsets(stream_state.offsets.get());
}
else if (stream_state.mesh->SpaceDimension() == 3)
{
Expand Down Expand Up @@ -224,6 +228,7 @@ bool GLVisInitVis(StreamCollection input_streams)
vs = new VisualizationSceneVector(*stream_state.mesh, stream_state.solu,
stream_state.solv, stream_state.mesh_quad.get());
}
vs->SetDataOffsets(stream_state.offsets.get());
}
else if (stream_state.mesh->SpaceDimension() == 3)
{
Expand Down
1 change: 1 addition & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ list(APPEND SOURCES
material.cpp
openglvis.cpp
palettes.cpp
palettes_default.cpp
palettes_base.cpp
sdl.cpp
sdl_helper.cpp
Expand Down
17 changes: 8 additions & 9 deletions lib/aux_vis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@

#include <iostream>
#include <sstream>
#include <fstream>
#include <cmath>
#include <chrono>
#include <regex>

#include "mfem.hpp"
#include "sdl.hpp"
#include "palettes.hpp"
#include "visual.hpp"
#include "gl/types.hpp"
#include "gl2ps.h"
#include "palettes.hpp"
#include "sdl.hpp"
#include "threads.hpp"

#include <mfem.hpp>

#if defined(GLVIS_USE_LIBTIFF)
#include "tiffio.h"
Expand All @@ -33,11 +34,9 @@
#include <fontconfig/fontconfig.h>
#endif

using namespace mfem;

thread_local int visualize = 0;
thread_local VisualizationScene * locscene;
thread_local GLVisCommand *glvis_command = NULL;
thread_local GLVisCommand *glvis_command = nullptr;

#ifdef GLVIS_MULTISAMPLE
static int glvis_multisample = GLVIS_MULTISAMPLE;
Expand Down Expand Up @@ -435,7 +434,7 @@ void MyExpose()
}


thread_local Array<void (*)()> IdleFuncs;
thread_local mfem::Array<void (*)()> IdleFuncs;
thread_local int LastIdleFunc;
thread_local bool use_idle = false;

Expand Down
3 changes: 1 addition & 2 deletions lib/aux_vis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#ifndef GLVIS_AUX_VIS_HPP
#define GLVIS_AUX_VIS_HPP

#include "gl/platform_gl.hpp"
#include "gl/types.hpp"

#include "openglvis.hpp"
Expand Down Expand Up @@ -184,4 +183,4 @@ function<bool(T)> validator = [](T) { return true; })
return input;
}

#endif
#endif // GLVIS_AUX_VIS_HPP
2 changes: 0 additions & 2 deletions lib/coll_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

#include "coll_reader.hpp"

#include <vector>

using namespace std;
using namespace mfem;

Expand Down
2 changes: 0 additions & 2 deletions lib/coll_reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
#ifndef GLVIS_COLL_READER_HPP
#define GLVIS_COLL_READER_HPP

#include <iostream>
#include "mfem.hpp"
#include "data_state.hpp"

class DataCollectionReader
Expand Down
90 changes: 68 additions & 22 deletions lib/data_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
// terms of the BSD-3 license. We welcome feedback and contributions, see file
// CONTRIBUTING.md for details.

#include "data_state.hpp"
#include "visual.hpp"

#include <cstdlib>

#include "data_state.hpp"
#include "vsvector.hpp"
#include "vsvector3d.hpp"

using namespace std;
using namespace mfem;

Expand Down Expand Up @@ -57,36 +58,82 @@ DataState &DataState::operator=(DataState &&ss)
return *this;
}

void DataState::SetMesh(mfem::Mesh *mesh_)
void DataState::SetMesh(Mesh *mesh_)
{
internal.mesh.reset(mesh_);
SetMesh(std::move(internal.mesh));
}

void DataState::SetMesh(std::unique_ptr<mfem::Mesh> &&pmesh)
void DataState::ComputeDofsOffsets(std::vector<mfem::GridFunction*> &gf_array)
{
const int nprocs = static_cast<int>(gf_array.size());
MFEM_VERIFY(!gf_array.empty(), "No grid functions provided for offsets");

internal.offsets.reset(new DataState::Offsets(nprocs));

DenseMatrix pointmat;
Array<int> dofs, vertices;
for (int i = 0, g_e = 0; i < nprocs; i++)
{
const GridFunction *gf = gf_array[i];
const FiniteElementSpace *l_fes = gf->FESpace();
Mesh *l_mesh = l_fes->GetMesh();
// store the dofs numbers as they are fespace dependent
auto &offset = offsets->operator[](i);
for (int l_e = 0; l_e < l_mesh->GetNE(); l_e++, g_e++)
{
#ifdef GLVIS_DEBUG
// Store elements centers
l_mesh->GetPointMatrix(l_e, pointmat);
const int nv = pointmat.Width();
double xs = 0.0, ys = 0.0;
for (int j = 0; j < nv; j++)
{
xs += pointmat(0,j), ys += pointmat(1,j);
}
xs /= nv, ys /= nv;
offset.exy_map[ {l_e, i} ] = {xs, ys};
#endif // end GLVIS_DEBUG
l_fes->GetElementDofs(l_e, dofs);
l_fes->AdjustVDofs(dofs);
for (int k = 0; k < dofs.Size(); k++)
{
offset[ {g_e, k} ] = dofs[k];
}
}
if (i + 1 == nprocs) { continue; }
auto &next = offsets->operator[](i+1);
// for NE, NV and NEdges, we accumulate the values
next.nelems = offset.nelems + l_mesh->GetNE();
next.nedges = offset.nedges + l_mesh->GetNEdges();
next.nverts = offset.nverts + l_mesh->GetNV();
}
}

void DataState::SetMesh(std::unique_ptr<Mesh> &&pmesh)
{
internal.mesh = std::move(pmesh);
internal.mesh_quad.reset();
if (grid_f && grid_f->FESpace()->GetMesh() != mesh.get()) { SetGridFunction(NULL); }
if (quad_f && quad_f->GetSpace()->GetMesh() != mesh.get()) { SetQuadFunction(NULL); }
}

void DataState::SetGridFunction(mfem::GridFunction *gf, int component)
void DataState::SetGridFunction(GridFunction *gf, int component)
{
internal.grid_f.reset(gf);
SetGridFunction(std::move(internal.grid_f), component);
}

void DataState::SetGridFunction(
std::unique_ptr<mfem::GridFunction> &&pgf, int component)
void DataState::SetGridFunction(std::unique_ptr<GridFunction> &&pgf,
int component)
{
internal.grid_f = std::move(pgf);
internal.quad_f.reset();
quad_sol = QuadSolution::NONE;
SetGridFunctionSolution(component);
}

void DataState::SetQuadFunction(mfem::QuadratureFunction *qf, int component)
void DataState::SetQuadFunction(QuadratureFunction *qf, int component)
{
if (quad_f.get() != qf)
{
Expand All @@ -97,8 +144,8 @@ void DataState::SetQuadFunction(mfem::QuadratureFunction *qf, int component)
SetQuadFunctionSolution(component);
}

void DataState::SetQuadFunction(
std::unique_ptr<mfem::QuadratureFunction> &&pqf, int component)
void DataState::SetQuadFunction(std::unique_ptr<QuadratureFunction> &&pqf,
int component)
{
if (quad_f.get() != pqf.get())
{
Expand All @@ -109,8 +156,8 @@ void DataState::SetQuadFunction(
SetQuadFunctionSolution(component);
}

void DataState::SetQuadFunction(
const std::vector<QuadratureFunction*> &qf_array, int component)
void DataState::SetQuadFunction(const std::vector<QuadratureFunction*>
&qf_array, int component)
{
// assume the same vdim
const int vdim = qf_array[0]->GetVDim();
Expand All @@ -132,7 +179,7 @@ void DataState::SetQuadFunction(
SetQuadFunction(qf, component);
}

void DataState::SetDataCollectionField(mfem::DataCollection *dc, int ti,
void DataState::SetDataCollectionField(DataCollection *dc, int ti,
const char *field, bool quad, int component)
{
internal.data_coll.reset(dc);
Expand Down Expand Up @@ -589,26 +636,26 @@ void DataState::ResetMeshAndSolution(DataState &ss, VisualizationScene* vs)
{
if (ss.grid_f->VectorDim() == 1)
{
VisualizationSceneSolution *vss =
dynamic_cast<VisualizationSceneSolution *>(vs);
auto *vss = dynamic_cast<VisualizationSceneSolution *>(vs);
// use the local vector as pointer is invalid after the move
ss.grid_f->GetNodalValues(sol);
// update the offsets before the mesh and solution
vss->SetDataOffsets(ss.offsets.get());
vss->NewMeshAndSolution(ss.mesh.get(), ss.mesh_quad.get(), &sol,
ss.grid_f.get());
}
else
{
VisualizationSceneVector *vsv =
dynamic_cast<VisualizationSceneVector *>(vs);
auto *vsv = dynamic_cast<VisualizationSceneVector *>(vs);
vsv->SetDataOffsets(ss.offsets.get());
vsv->NewMeshAndSolution(*ss.grid_f, ss.mesh_quad.get());
}
}
else
{
if (ss.grid_f->VectorDim() == 1)
{
VisualizationSceneSolution3d *vss =
dynamic_cast<VisualizationSceneSolution3d *>(vs);
auto *vss = dynamic_cast<VisualizationSceneSolution3d *>(vs);
// use the local vector as pointer is invalid after the move
ss.grid_f->GetNodalValues(sol);
vss->NewMeshAndSolution(ss.mesh.get(), ss.mesh_quad.get(), &sol,
Expand All @@ -618,8 +665,7 @@ void DataState::ResetMeshAndSolution(DataState &ss, VisualizationScene* vs)
{
ss.ProjectVectorFEGridFunction();

VisualizationSceneVector3d *vss =
dynamic_cast<VisualizationSceneVector3d *>(vs);
auto *vss = dynamic_cast<VisualizationSceneVector3d *>(vs);
vss->NewMeshAndSolution(ss.mesh.get(), ss.mesh_quad.get(), ss.grid_f.get());
}
}
Expand Down
Loading
Loading