Skip to content

OglFluidModel

Particle model for OpenGL display, using glsl

Vec3d

Templates:

  • Vec3d

Target: SofaSphFluid

namespace: sofa::component::visualmodel

parents:

  • VisualModel

Data

Name Description Default value
name object name unnamed
printLog if true, emits extra messages at runtime. 0
tags list of the subsets the objet belongs to
bbox this object bounding box
componentState The state of the component among (Dirty, Valid, Undefined, Loading, Invalid). Undefined
listening if true, handle the events, otherwise ignore the events 0
enable Display the object or not 1
position Vertices coordinates
debugFBO DEBUG FBO 9
spriteRadius Radius of sprites 1
spriteThickness Thickness of sprites 0.01
spriteBlurRadius Blur radius (in pixels) 10
spriteBlurScale Blur scale 0.1
spriteBlurDepthFalloff Blur Depth Falloff 1
spriteDiffuseColor Diffuse Color 0 0 1 1
Name Description Destination type name
context Graph Node containing this object (or BaseContext::getDefault() if no graph is used) BaseContext
slaves Sub-objects used internally by this object BaseObject
master nullptr for regular objects, or master object for which this object is one sub-objects BaseObject

Examples

OglFluidModel_SPH.scn

<?xml version="1.0" ?>
<Node dt="0.01" gravity="0 -20 0.0" >
    <RequiredPlugin name="Sofa.Component.Mass"/> <!-- Needed to use components [UniformMass] -->
    <RequiredPlugin name="Sofa.Component.MechanicalLoad"/> <!-- Needed to use components [PlaneForceField] -->
    <RequiredPlugin name="Sofa.Component.ODESolver.Forward"/> <!-- Needed to use components [EulerExplicitSolver] -->
    <RequiredPlugin name="Sofa.Component.StateContainer"/> <!-- Needed to use components [MechanicalObject] -->
    <RequiredPlugin name="Sofa.Component.Topology.Container.Grid"/> <!-- Needed to use components [RegularGridTopology] -->
    <RequiredPlugin name="Sofa.Component.Visual"/> <!-- Needed to use components [VisualStyle] -->
    <RequiredPlugin name="SofaSphFluid"/> <!-- Needed to use components [OglFluidModel SPHFluidForceField SpatialGridContainer] -->
    <VisualStyle displayFlags="hideBehaviorModels hideForceFields hideCollisionModels" />

    <DefaultAnimationLoop/>
    <Node name="SPH" >
        <EulerExplicitSolver symplectic="1" />
        <RegularGridTopology nx="5" ny="400" nz="5" xmin="-3.0" xmax="0" ymin="-3" ymax="36" zmin="-3.0" zmax="0" />
        <MechanicalObject name="MModel" />
        <!-- A topology is used here just to set initial particles positions. It is a bad idea because this object has no real topology, but it works... -->
        <UniformMass name="M1" vertexMass="1" />
        <SpatialGridContainer cellWidth="0.75" />
        <SPHFluidForceField radius="0.745" density="15" kernelType="1" viscosityType="2" viscosity="10" pressure="1000" surfaceTension="-1000" printLog="0" />
        <!-- The following force fields handle collision with walls and an inclined floor -->
        <PlaneForceField normal="1 0 0" d="-4" />
        <PlaneForceField normal="-1 0 0" d="-4" />
        <PlaneForceField normal="0.5 1 0.1" d="-4" />
        <PlaneForceField normal="0 0 1" d="-10" />
        <PlaneForceField normal="0 0 -1" d="-10" />
    </Node>

    <Node name="Fluid" >            
        <OglFluidModel template="Vec3d" position="@../SPH/MModel.position" 
            debugFBO="9"
            spriteRadius="0.5" spriteThickness="0.015" spriteBlurRadius="10" spriteBlurScale="10" spriteBlurDepthFalloff="1"  />
    </Node>
</Node>
def createScene(root_node):

   node = root_node.addChild('node', dt="0.01", gravity="0 -20 0.0")

   node.addObject('RequiredPlugin', name="Sofa.Component.Mass")
   node.addObject('RequiredPlugin', name="Sofa.Component.MechanicalLoad")
   node.addObject('RequiredPlugin', name="Sofa.Component.ODESolver.Forward")
   node.addObject('RequiredPlugin', name="Sofa.Component.StateContainer")
   node.addObject('RequiredPlugin', name="Sofa.Component.Topology.Container.Grid")
   node.addObject('RequiredPlugin', name="Sofa.Component.Visual")
   node.addObject('RequiredPlugin', name="SofaSphFluid")
   node.addObject('VisualStyle', displayFlags="hideBehaviorModels hideForceFields hideCollisionModels")
   node.addObject('DefaultAnimationLoop', )

   sph = node.addChild('SPH')

   sph.addObject('EulerExplicitSolver', symplectic="1")
   sph.addObject('RegularGridTopology', nx="5", ny="400", nz="5", xmin="-3.0", xmax="0", ymin="-3", ymax="36", zmin="-3.0", zmax="0")
   sph.addObject('MechanicalObject', name="MModel")
   sph.addObject('UniformMass', name="M1", vertexMass="1")
   sph.addObject('SpatialGridContainer', cellWidth="0.75")
   sph.addObject('SPHFluidForceField', radius="0.745", density="15", kernelType="1", viscosityType="2", viscosity="10", pressure="1000", surfaceTension="-1000", printLog="0")
   sph.addObject('PlaneForceField', normal="1 0 0", d="-4")
   sph.addObject('PlaneForceField', normal="-1 0 0", d="-4")
   sph.addObject('PlaneForceField', normal="0.5 1 0.1", d="-4")
   sph.addObject('PlaneForceField', normal="0 0 1", d="-10")
   sph.addObject('PlaneForceField', normal="0 0 -1", d="-10")

   fluid = node.addChild('Fluid')

   fluid.addObject('OglFluidModel', template="Vec3d", position="@../SPH/MModel.position", debugFBO="9", spriteRadius="0.5", spriteThickness="0.015", spriteBlurRadius="10", spriteBlurScale="10", spriteBlurDepthFalloff="1")

OglFluidModel_SPHParticles.scn

<?xml version="1.0" ?>
<Node dt="0.01" gravity="0 -10 0" bbox="-6 -6 -6  6 6 6">
    <RequiredPlugin name="Sofa.Component.Mass"/> <!-- Needed to use components [UniformMass] -->
    <RequiredPlugin name="Sofa.Component.ODESolver.Forward"/> <!-- Needed to use components [EulerExplicitSolver] -->
    <RequiredPlugin name="Sofa.Component.StateContainer"/> <!-- Needed to use components [MechanicalObject] -->
    <RequiredPlugin name="Sofa.Component.Topology.Container.Dynamic"/> <!-- Needed to use components [PointSetTopologyContainer PointSetTopologyModifier] -->
    <RequiredPlugin name="Sofa.Component.Visual"/> <!-- Needed to use components [VisualStyle] -->
    <RequiredPlugin name="SofaSphFluid"/> <!-- Needed to use components [OglFluidModel ParticleSink ParticleSource SPHFluidForceField SpatialGridContainer] -->
    <VisualStyle displayFlags="hideBehaviorModels hideForceFields hideWireframe" />

    <DefaultAnimationLoop/>
    <Node name="Particles">
        <EulerExplicitSolver symplectic="1" />
        <MechanicalObject name="MModel"/>
        <ParticleSource name="Source" translation="0 20 0" radius="0.01 0.1 0.01" velocity="0 -10 0" delay="0.02" start="0.0" stop="10" printLog="0"
        center="-0.375 0 -0.75 
            0.0 0.0 -0.75 
            0.375 0.0 -0.75 
            -0.75  0.0 -0.375 
            -0.375 0.0 -0.375 
            0.0 0.0 -0.375 
            0.375 0.0 -0.375 
            0.75 0.0 -0.375 
            -0.75 0.0 0.0 
            -0.375 0.0 0.0 
            0.0 0.0 0.0 
            0.375 0.0 0.0 
            0.75 0.0 0.0 
            -0.75 0.0 0.375 
            -0.375 0.0 0.375 
            0.0 0.0 0.375 
            0.375 0.0 0.375 
            0.75 0.0 0.375 
            -0.375 0.0 0.75 
            0.0 0.0 0.75 
            0.375 0.0 0.75"  />

        <UniformMass name="M1" vertexMass="1.0" />
        <PointSetTopologyContainer name="con" />
        <PointSetTopologyModifier name="mod" />

        <SpatialGridContainer cellWidth="0.75" />
        <SPHFluidForceField radius="0.7" density="25" kernelType="1" viscosityType="2" viscosity="10" pressure="1000" surfaceTension="-1000" printLog="0" />

        <ParticleSink name="sink" normal="0 1 0" d0="1" d1="0" showPlane="0" printLog="0" />
        <Node name="Fluid" >            
            <OglFluidModel template="Vec3d" position="@../MModel.position" 
                debugFBO="9"
                spriteRadius="0.5" spriteThickness="0.015" spriteBlurRadius="10" spriteBlurScale="10" spriteBlurDepthFalloff="1"  />
        </Node>
    </Node>
</Node>
def createScene(root_node):

   node = root_node.addChild('node', dt="0.01", gravity="0 -10 0", bbox="-6 -6 -6  6 6 6")

   node.addObject('RequiredPlugin', name="Sofa.Component.Mass")
   node.addObject('RequiredPlugin', name="Sofa.Component.ODESolver.Forward")
   node.addObject('RequiredPlugin', name="Sofa.Component.StateContainer")
   node.addObject('RequiredPlugin', name="Sofa.Component.Topology.Container.Dynamic")
   node.addObject('RequiredPlugin', name="Sofa.Component.Visual")
   node.addObject('RequiredPlugin', name="SofaSphFluid")
   node.addObject('VisualStyle', displayFlags="hideBehaviorModels hideForceFields hideWireframe")
   node.addObject('DefaultAnimationLoop', )

   particles = node.addChild('Particles')

   particles.addObject('EulerExplicitSolver', symplectic="1")
   particles.addObject('MechanicalObject', name="MModel")
   particles.addObject('ParticleSource', name="Source", translation="0 20 0", radius="0.01 0.1 0.01", velocity="0 -10 0", delay="0.02", start="0.0", stop="10", printLog="0", center="-0.375 0 -0.75              0.0 0.0 -0.75              0.375 0.0 -0.75              -0.75  0.0 -0.375              -0.375 0.0 -0.375              0.0 0.0 -0.375              0.375 0.0 -0.375              0.75 0.0 -0.375              -0.75 0.0 0.0              -0.375 0.0 0.0              0.0 0.0 0.0              0.375 0.0 0.0              0.75 0.0 0.0              -0.75 0.0 0.375              -0.375 0.0 0.375              0.0 0.0 0.375              0.375 0.0 0.375              0.75 0.0 0.375              -0.375 0.0 0.75              0.0 0.0 0.75              0.375 0.0 0.75")
   particles.addObject('UniformMass', name="M1", vertexMass="1.0")
   particles.addObject('PointSetTopologyContainer', name="con")
   particles.addObject('PointSetTopologyModifier', name="mod")
   particles.addObject('SpatialGridContainer', cellWidth="0.75")
   particles.addObject('SPHFluidForceField', radius="0.7", density="25", kernelType="1", viscosityType="2", viscosity="10", pressure="1000", surfaceTension="-1000", printLog="0")
   particles.addObject('ParticleSink', name="sink", normal="0 1 0", d0="1", d1="0", showPlane="0", printLog="0")

   fluid = Particles.addChild('Fluid')

   fluid.addObject('OglFluidModel', template="Vec3d", position="@../MModel.position", debugFBO="9", spriteRadius="0.5", spriteThickness="0.015", spriteBlurRadius="10", spriteBlurScale="10", spriteBlurDepthFalloff="1")