Skip to content

Commit d5172c9

Browse files
committed
- added ParaView partio plugin
- extended tooltips by json key - small avx improvements - fluid can have an initial angular velocity - improved Maya plugin - added support of asynchronous file writing in the partio exporter - added reset callback
1 parent 2247a87 commit d5172c9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1161
-324
lines changed

CMake/Common.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ if (UNIX OR MINGW)
8888
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
8989
if (USE_AVX)
9090
add_compile_options("-mavx")
91+
add_compile_options("-mfma")
9192
endif()
9293
endif (UNIX OR MINGW)
9394
if(MINGW)

Changelog.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
2.9.2
2+
- added ParaView partio plugin
3+
- extended tooltips by json key
4+
- small avx improvements
5+
- fluid can have an initial angular velocity
6+
- improved Maya plugin
7+
- added support of asynchronous file writing in the partio exporter
8+
- added reset callback
9+
2.9.1
110
- added documentation about how to implement an exporter
211
- added a Python data exporter example (can export rigid bodies in all formats supported by meshio)
312
- added an OBJ rigid body exporter

GUI/OpenGL/MiniGL.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ void MiniGL::init(int argc, char **argv, const int width, const int height, cons
487487
//glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
488488
//glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
489489

490+
//glfwWindowHint(GLFW_DOUBLEBUFFER, GL_FALSE);
490491
m_glfw_window = glfwCreateWindow(width, height, name, NULL, NULL);
491492
if (!m_glfw_window)
492493
{
@@ -496,7 +497,7 @@ void MiniGL::init(int argc, char **argv, const int width, const int height, cons
496497

497498
glfwMakeContextCurrent(m_glfw_window);
498499
gladLoadGL(glfwGetProcAddress);
499-
glfwSwapInterval(1);
500+
glfwSwapInterval(0);
500501

501502
glfwSetFramebufferSizeCallback(m_glfw_window, reshape);
502503

@@ -963,6 +964,7 @@ void MiniGL::mainLoop()
963964
scenefunc();
964965

965966
glfwSwapBuffers(m_glfw_window);
967+
//glFlush();
966968
}
967969

968970
if (destroyfunc != nullptr)
@@ -983,6 +985,7 @@ void MiniGL::leaveMainLoop()
983985
void MiniGL::swapBuffers()
984986
{
985987
glfwSwapBuffers(m_glfw_window);
988+
//glFlush();
986989
}
987990

988991
void MiniGL::breakPointMainLoop()
@@ -999,6 +1002,7 @@ void MiniGL::breakPointMainLoop()
9991002
scenefunc();
10001003

10011004
glfwSwapBuffers(m_glfw_window);
1005+
//glFlush();
10021006
glfwPollEvents();
10031007
}
10041008
}

GUI/imgui/imguiParameters.cpp

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,11 @@ void imguiParameters::createStringParameter(imguiParameters::imguiParameter* par
6666
if ((sparam != nullptr) && (sparam->getFct != nullptr))
6767
{
6868
std::string str = sparam->getFct();
69-
char value[1000];
69+
const unsigned int buf_size = 1000;
70+
char value[buf_size];
7071
strcpy(value, str.c_str());
7172

72-
ImGui::InputText(sparam->label.c_str(), value, str.length(), flags);
73+
ImGui::InputText(sparam->label.c_str(), value, buf_size, flags);
7374

7475
if (ImGui::IsItemDeactivatedAfterEdit())
7576
{
@@ -187,6 +188,8 @@ void imguiParameters::createSubgroupParameters(const std::vector<std::pair<std::
187188
std::string helpText = param->description;
188189
if (param->readOnly)
189190
helpText += " (read-only)";
191+
else if (param->name != "")
192+
helpText += "\n\nkey in scene file:\n" + param->name;
190193

191194
ImGuiInputTextFlags flags = 0;
192195
if (param->readOnly)
@@ -304,9 +307,19 @@ void imguiParameters::createParameterObjectGUI(ParameterObject* paramObj)
304307
if (group == "General")
305308
subgroup = group;
306309

310+
if (group == "Export")
311+
subgroup = "General";
312+
313+
if ((group == "Particle exporters") || (group == "Rigid body exporters"))
314+
{
315+
subgroup = group;
316+
group = "Export";
317+
}
318+
307319
if (paramBase->getType() == RealParameterType)
308320
{
309321
imguiParameters::imguiNumericParameter<Real>* param = new imguiParameters::imguiNumericParameter<Real>();
322+
param->name = paramBase->getName();
310323
param->description = paramBase->getDescription();
311324
param->label = paramBase->getLabel();
312325
param->readOnly = paramBase->getReadOnly();
@@ -319,6 +332,7 @@ void imguiParameters::createParameterObjectGUI(ParameterObject* paramObj)
319332
else if (paramBase->getType() == ParameterBase::UINT32)
320333
{
321334
imguiParameters::imguiNumericParameter<unsigned int>* param = new imguiParameters::imguiNumericParameter<unsigned int>();
335+
param->name = paramBase->getName();
322336
param->description = paramBase->getDescription();
323337
param->label = paramBase->getLabel();
324338
param->readOnly = paramBase->getReadOnly();
@@ -331,6 +345,7 @@ void imguiParameters::createParameterObjectGUI(ParameterObject* paramObj)
331345
else if (paramBase->getType() == ParameterBase::UINT16)
332346
{
333347
imguiParameters::imguiNumericParameter<unsigned short>* param = new imguiParameters::imguiNumericParameter<unsigned short>();
348+
param->name = paramBase->getName();
334349
param->description = paramBase->getDescription();
335350
param->label = paramBase->getLabel();
336351
param->readOnly = paramBase->getReadOnly();
@@ -343,6 +358,7 @@ void imguiParameters::createParameterObjectGUI(ParameterObject* paramObj)
343358
else if (paramBase->getType() == ParameterBase::UINT8)
344359
{
345360
imguiParameters::imguiNumericParameter<unsigned char>* param = new imguiParameters::imguiNumericParameter<unsigned char>();
361+
param->name = paramBase->getName();
346362
param->description = paramBase->getDescription();
347363
param->label = paramBase->getLabel();
348364
param->readOnly = paramBase->getReadOnly();
@@ -355,6 +371,7 @@ void imguiParameters::createParameterObjectGUI(ParameterObject* paramObj)
355371
else if (paramBase->getType() == ParameterBase::INT32)
356372
{
357373
imguiParameters::imguiNumericParameter<int>* param = new imguiParameters::imguiNumericParameter<int>();
374+
param->name = paramBase->getName();
358375
param->description = paramBase->getDescription();
359376
param->label = paramBase->getLabel();
360377
param->readOnly = paramBase->getReadOnly();
@@ -367,6 +384,7 @@ void imguiParameters::createParameterObjectGUI(ParameterObject* paramObj)
367384
else if (paramBase->getType() == ParameterBase::INT16)
368385
{
369386
imguiParameters::imguiNumericParameter<short>* param = new imguiParameters::imguiNumericParameter<short>();
387+
param->name = paramBase->getName();
370388
param->description = paramBase->getDescription();
371389
param->label = paramBase->getLabel();
372390
param->readOnly = paramBase->getReadOnly();
@@ -379,6 +397,7 @@ void imguiParameters::createParameterObjectGUI(ParameterObject* paramObj)
379397
else if (paramBase->getType() == ParameterBase::INT8)
380398
{
381399
imguiParameters::imguiNumericParameter<char>* param = new imguiParameters::imguiNumericParameter<char>();
400+
param->name = paramBase->getName();
382401
param->description = paramBase->getDescription();
383402
param->label = paramBase->getLabel();
384403
param->readOnly = paramBase->getReadOnly();
@@ -391,6 +410,7 @@ void imguiParameters::createParameterObjectGUI(ParameterObject* paramObj)
391410
else if (paramBase->getType() == ParameterBase::BOOL)
392411
{
393412
imguiParameters::imguiBoolParameter* param = new imguiParameters::imguiBoolParameter();
413+
param->name = paramBase->getName();
394414
param->description = paramBase->getDescription();
395415
param->label = paramBase->getLabel();
396416
param->readOnly = paramBase->getReadOnly();
@@ -401,6 +421,7 @@ void imguiParameters::createParameterObjectGUI(ParameterObject* paramObj)
401421
else if (paramBase->getType() == ParameterBase::ENUM)
402422
{
403423
imguiParameters::imguiEnumParameter* param = new imguiParameters::imguiEnumParameter();
424+
param->name = paramBase->getName();
404425
param->description = paramBase->getDescription();
405426
param->label = paramBase->getLabel();
406427
param->readOnly = paramBase->getReadOnly();
@@ -414,6 +435,7 @@ void imguiParameters::createParameterObjectGUI(ParameterObject* paramObj)
414435
else if (paramBase->getType() == ParameterBase::STRING)
415436
{
416437
imguiParameters::imguiStringParameter* param = new imguiParameters::imguiStringParameter();
438+
param->name = paramBase->getName();
417439
param->description = paramBase->getDescription();
418440
param->label = paramBase->getLabel();
419441
param->readOnly = paramBase->getReadOnly();
@@ -424,6 +446,7 @@ void imguiParameters::createParameterObjectGUI(ParameterObject* paramObj)
424446
else if ((paramBase->getType() == RealVectorParameterType) && (static_cast<RealVectorParameter*>(paramBase)->getDim() == 3))
425447
{
426448
imguiParameters::imguiVec3rParameter* param = new imguiParameters::imguiVec3rParameter();
449+
param->name = paramBase->getName();
427450
param->description = paramBase->getDescription();
428451
param->label = paramBase->getLabel();
429452
param->readOnly = paramBase->getReadOnly();
@@ -434,6 +457,7 @@ void imguiParameters::createParameterObjectGUI(ParameterObject* paramObj)
434457
else if (paramBase->getType() == ParameterBase::FUNCTION)
435458
{
436459
imguiParameters::imguiFunctionParameter* param = new imguiParameters::imguiFunctionParameter();
460+
param->name = paramBase->getName();
437461
param->description = paramBase->getDescription();
438462
param->label = paramBase->getLabel();
439463
param->readOnly = false;

GUI/imgui/imguiParameters.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ namespace SPH
2121
public:
2222
struct imguiParameter
2323
{
24+
std::string name;
2425
std::string label;
2526
std::string description;
2627
bool readOnly;

SPlisHSPlasH/DFSPH/TimeStepDFSPH.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -630,9 +630,11 @@ void TimeStepDFSPH::pressureSolveIteration(const unsigned int fluidModelIndex, R
630630
const Scalarf8 densityAdvj_avx = convert_zero(&sim->getNeighborList(fluidModelIndex, pid, i)[j], &m_simulationData.getDensityAdv(pid, 0), count);
631631
const Scalarf8 factorj_avx = convert_zero(&sim->getNeighborList(fluidModelIndex, pid, i)[j], &m_simulationData.getFactor(pid, 0), count);
632632

633-
const Scalarf8 b_j_avx = densityAdvj_avx - Scalarf8(1.0f);
634-
const Scalarf8 kj_avx = b_j_avx * factorj_avx;
635-
const Scalarf8 kSum_avx = ki_avx + densityFrac_avx * kj_avx;
633+
//const Scalarf8 b_j_avx = densityAdvj_avx - Scalarf8(1.0f);
634+
//const Scalarf8 kj_avx = b_j_avx * factorj_avx;
635+
const Scalarf8 kj_avx = multiplyAndSubtract(densityAdvj_avx, factorj_avx, factorj_avx);
636+
//const Scalarf8 kSum_avx = ki_avx + densityFrac_avx * kj_avx;
637+
const Scalarf8 kSum_avx = multiplyAndAdd(densityFrac_avx, kj_avx, ki_avx);
636638

637639
// Directly update velocities instead of storing pressure accelerations
638640
delta_vi += V_gradW * (h_avx * kSum_avx); // ki, kj already contain inverse density
@@ -871,7 +873,7 @@ void TimeStepDFSPH::divergenceSolveIteration(const unsigned int fluidModelIndex,
871873
const Scalarf8 factorj_avx = convert_zero(&sim->getNeighborList(fluidModelIndex, pid, i)[j], &m_simulationData.getFactor(pid, 0), count);
872874

873875
const Scalarf8 kj_avx = densityAdvj_avx * factorj_avx;
874-
const Scalarf8 kSum_avx = ki_avx + densityFrac_avx * kj_avx;
876+
const Scalarf8 kSum_avx = multiplyAndAdd(densityFrac_avx, kj_avx, ki_avx);
875877

876878
// Directly update velocities instead of storing pressure accelerations
877879
delta_vi += V_gradW * (h_avx * kSum_avx); // ki, kj already contain inverse density

SPlisHSPlasH/Elasticity/Elasticity_Peer2018.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ Elasticity_Peer2018::Elasticity_Peer2018(FluidModel *model) :
3131
m_iterations = 0;
3232
m_maxIter = 100;
3333
m_maxError = static_cast<Real>(1.0e-4);
34-
m_alpha = 0.0;
35-
36-
initValues();
34+
m_alpha = 0.0;
3735

3836
model->addField({ "rest volume", FieldType::Scalar, [&](const unsigned int i) -> Real* { return &m_restVolumes[i]; }, true });
3937
model->addField({ "rotation", FieldType::Matrix3, [&](const unsigned int i) -> Real* { return &m_rotations[i](0,0); } });
@@ -51,6 +49,10 @@ Elasticity_Peer2018::~Elasticity_Peer2018(void)
5149
m_model->removeFieldByName("correction matrix");
5250
}
5351

52+
void Elasticity_Peer2018::deferredInit()
53+
{
54+
initValues();
55+
}
5456

5557
void Elasticity_Peer2018::initParameters()
5658
{

SPlisHSPlasH/Elasticity/Elasticity_Peer2018.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ namespace SPH
4444
void computeRHS(VectorXr & rhs);
4545

4646
virtual void initParameters();
47+
/** This function is called after the simulation scene is loaded and all
48+
* parameters are initialized. While reading a scene file several parameters
49+
* can change. The deferred init function should initialize all values which
50+
* depend on these parameters.
51+
*/
52+
virtual void deferredInit();
4753

4854
//////////////////////////////////////////////////////////////////////////
4955
// multiplication of symmetric matrix, represented by a 6D vector, and a

SPlisHSPlasH/FluidModel.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,21 @@ void FluidModel::init()
8888
setViscosityMethod(1);
8989
}
9090

91+
void FluidModel::deferredInit()
92+
{
93+
if (m_surfaceTension)
94+
m_surfaceTension->deferredInit();
95+
if (m_viscosity)
96+
m_viscosity->deferredInit();
97+
if (m_vorticity)
98+
m_vorticity->deferredInit();
99+
if (m_drag)
100+
m_drag->deferredInit();
101+
if (m_elasticity)
102+
m_elasticity->deferredInit();
103+
}
104+
105+
91106
void FluidModel::initParameters()
92107
{
93108
std::string groupName = "FluidModel";

SPlisHSPlasH/FluidModel.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ namespace SPH
9393
virtual ~FluidModel();
9494

9595
void init();
96+
/** This function is called after the simulation scene is loaded and all
97+
* parameters are initialized. While reading a scene file several parameters
98+
* can change. The deferred init function should initialize all values which
99+
* depend on these parameters.
100+
*/
101+
void deferredInit();
96102

97103
std::string getId() const { return m_id; }
98104

0 commit comments

Comments
 (0)