Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

Revision 92d43fb1eea21ec77fe31adc0b0c999f1a124737 authored by Nils Thuerey on 08 June 2017, 20:22:23 UTC, committed by Nils Thuerey on 08 June 2017, 20:22:23 UTC
screens
1 parent 0b4d265
  • Files
  • Changes
  • 5d19b9f
  • /
  • scenes
  • /
  • flip03_gen.py
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • revision
  • directory
  • content
revision badge
swh:1:rev:92d43fb1eea21ec77fe31adc0b0c999f1a124737
directory badge
swh:1:dir:8046bfcf9852b9019a6879130764073eab66a024
content badge
swh:1:cnt:73ba265f60d0c439a72e19613c498e2f0da4d7fb

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • revision
  • directory
  • content
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
flip03_gen.py
#
# Flip surface mesh creation scene, note - saves & loads (ie plays back) meshes in UI mode
# 
from manta import *
import os
   
mantaMsg( "\nNote - this scene reads in particle data generated by, e.g., flip02_surface.py (set saveParts=True there). It does not perform any fluid simulation, only generate a nicer surface.\n" )


# === surface generation parameters ===

# input file 
partfile   = 'flipParts_%04d.uni' 
startFrame = 1
endFrame   = 1000
interval   = 1

# how much larger?
upres = 2.0

# output file name so that blender can directly read it...
meshfile = 'fluidsurface_final_%04d.bobj.gz' 

# resolution for level set / output mesh
refName = ("ref_" + (partfile % 0) ) 
gs = getUniFileSize(refName)
if gs.x<=0: 
	mantaMsg("Warning! File '%s' not found, cannot determine size...\n"%refName, 0)
	exit(1)

gs.x = int(gs.x*upres)
gs.y = int(gs.y*upres)
gs.z = int(gs.z*upres)
s = Solver(name='main', gridSize = gs , dim=3)

# kernel radius for surface creation
radiusFactor = 2.5

# triangle scale relative to cell size
#scale = 0.5

# counters
outCnt = 0
frame = startFrame


# prepare grids and particles
flags    = s.create(FlagGrid)
phi      = s.create(LevelsetGrid)
pp       = s.create(BasicParticleSystem) 
mesh     = s.create(Mesh)

# acceleration data for particle nbs
pindex = s.create(ParticleIndexSystem) 
gpi    = s.create(IntGrid)

# scene setup
flags.initDomain(boundaryWidth=0)
	
if 1 and (GUI):
	gui = Gui()
	gui.show()
	#gui.pause()


# main loop

while frame < endFrame:
	meshfileCurr = meshfile % outCnt 
	mantaMsg( "Frame %d " % frame )
	phi.setBound(value=0., boundaryWidth=1)

	# already exists?
	if (os.path.isfile( meshfileCurr )):
		mesh.load( meshfileCurr )

	else:
		# generate mesh; first read input sim particles
		if (os.path.isfile( partfile % frame )):
			pp.load( partfile % frame );
			
			# create surface
			gridParticleIndex( parts=pp , flags=flags, indexSys=pindex, index=gpi )
			#unionParticleLevelset( pp, pindex, flags, gpi, phi , radiusFactor ) # faster, but not as smooth
			averagedParticleLevelset( pp, pindex, flags, gpi, phi , radiusFactor , 1, 1 ) 

			phi.setBound(value=0., boundaryWidth=1)
			phi.createMesh(mesh)

			# beautify mesh, too slow right now!
			#subdivideMesh(mesh=mesh, minAngle=0.01, minLength=scale, maxLength=3*scale, cutTubes=False) 
			# perform smoothing
			#for iters in range(10):
				#smoothMesh(mesh=mesh, strength=1e-3, steps=10) 
				#subdivideMesh(mesh=mesh, minAngle=0.01, minLength=scale, maxLength=3*scale, cutTubes=True)

			# write output file:
			mesh.save( meshfileCurr )
		else:
			# stop playback for UI, reset
			if (GUI):
				gui.pause()
				outCnt = 0

	#gui.screenshot( 'flip03_%04d.png' % outCnt ); 
	outCnt += 1
	frame  += interval
	s.step()
	

The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API