Forum Replies Created
-
AuthorPosts
-
mbarrowBlocked
Hi Hugo,
thanks this worked perfectly!
23 November 2018 at 08:08 in reply to: Bug. Mismatch between image plugin .obj and .png co-ordinate systems #12522mbarrowBlockedYes I don’t understand that component. I saw it used in beamFEMForceField.scn but I was not successful when I placed it in the same node as the RegularGridTopology that is used for the FEM forcefield. I can keep trying but just giving an update since you ask
20 November 2018 at 08:26 in reply to: How to make a 6DOF simulation act like a 4DOF (make 3d act like 2d simulation)? #12504mbarrowBlockedHi Hugo, I wanted to hold of responding before some thorough testing of this suggestion.
Thank you, it seems to work in most cases. If anyone reads this and has a choice, Vec2d would be a much more robust solution. I also struggled to find any information on the constraint bit mask parameters. Could you please confirm which degrees of freedom the 12 bits correspond to?
here is an example where I have only allowed motion along a single axis for all indices in my mechanical object. I also seem to have prevented torquing (and the subsequent failure of the constraint if torquing occurs)
`<PartialFixedConstraint fixAll=”true” fixedDirections=”1 0 1 0 0 1 0 0 1 0 0 0″ />
Thanks again
mbarrowBlockedHi Fayad.
I saw something similar when I had inappropriate values for ContactStiffness set, only I have to qualify this with the fact I was using only the Triangle Collision model.
Good luck!
2 November 2018 at 19:34 in reply to: [SOLVED] how to use node output as "param" for ImageFilter? #12326mbarrowBlockedThanks for looking at this Hugo.
I had gotten confused about how the image filter works. I think this thread would be better of being deleted
30 October 2018 at 05:17 in reply to: [SOLVED] how to use node output as "param" for ImageFilter? #12299mbarrowBlockedIgnore this question. It makes no sense what I was trying to do.
mbarrowBlockedHi Carlos. I think if you re-run Cmake GUI in your directory of built code you will not need to re-compile from the start. Only the additional stuff will need to be built when you compile using “make” after generating the build files from Cmake and exiting the GUI.
You could try the following steps, maybe they will work.
When you are using CMake GUI, make sure to check the following options
* Sofa python
* Image
* FlexibleSorry I forget the precise names of the three components but you need all three.
Good luck.
29 October 2018 at 17:42 in reply to: [SOLVED] how to use node output as "param" for ImageFilter? #12295mbarrowBlockedTo anyone who has time to look at this, here is a link to the image in the code snippet: here is a 100×500 white beam png image
Cheers
29 October 2018 at 17:40 in reply to: Bug. Mismatch between image plugin .obj and .png co-ordinate systems #12294mbarrowBlockedsure, here is a 100×500 white beam png image
thanks for the suggestions I will try them. This link is also good for my other question which is actually quite a lot more pressing for me if you could take a look?
its here: how to use node output as “param” for ImageFilter?
Thanks very much for responding to my questions
mbarrowBlockedHi Hugo, sorry I was tired when I posted that, the self.variables should come from the python controller node in the scn. The first is to the collision mesh and the second is just a file name for some output JSON
<PythonScriptController filename="steaklog.py" classname="Modulus_Log" variables="../../collision/mesh ../../collision/pts youngsdata.json"/>
Is this the answer to your question?
Let me know, thanks
mbarrowBlockedHugo, I took a quite different approach to the python using some example python code in the Flexible plugin directory. It seems to sample the modulus image using a mesh, but I’m not sure if it really does the right thing. Could you confirm I am on the right path here? I’ve supplied the code for the python container.
Thanks.
import os import Sofa import json from numpy import indices # helper functions def getNode(rootNode, path): currentNode = rootNode pathComponents = path.split('/') for c in pathComponents: if len(c)==0: # for leading '/' and in case of '//' continue if c=='..': currentNode = currentNode.getParents()[0] else: currentNode = currentNode.getChild(c) if currentNode is None: print "SofaPython.Tools.findNode: can't find node at", path return None return currentNode # variables; self.variables[0][0] = path to mesh self.variables[0][0] = path to pts class Modulus_Log(Sofa.PythonScriptController): def createGraph(self,node): meshpath = self.variables[0][0] ptspath = self.variables[1][0] self.outfile= self.variables[2][0] [path,obj]=ptspath.rsplit('/',1) #get path to 'pts' object as supplied to the script self.movingpts=getNode(node,path).getObject(obj) self.mynode = node.createChild('DataLogging') self.mesh = self.mynode.createObject('TriangleSetTopologyContainer',name='mesh', src='@../'+meshpath) self.youngsIndices=self.mynode.createObject( 'ImageValuesFromPositions', template='ImageUI', name='youngsIndices', position='@mesh.position', image='@../../sampler.region', transform='@../../sampler.transform' , interpolation='0' ) self.mynode.createObject('IdentityMapping',input='@../'+ptspath, output='@.') return 0 #Log data that you want in a decent format. you could use vtk json whatever. def cleanup(self): #get mapped youngs modulus values (mapped from an image sampler to the closest exterior points of mesh) and log them out. youngMidx = self.youngsIndices.findData('values').value allYM = self.ffield.findData('youngModulus').value YM = [allYM[int(item[0])] for index, item in enumerate(youngMidx)] #get displaced mesh point positions and log those out too ptsXYZ=self.movingpts.getData('position').value rptsXYZ=self.movingpts.getData('rest_position').value T = self.mesh.getData('triangles').value print('logging out data...') output = dict() output['rest_position']=rptsXYZ output['position']=ptsXYZ output['triangles']=T output['youngsM']=YM with open(self.outfile,'w') as file: try: json.dump(output, file) except IOError: raise if self.outfile[0] != '/': print('saved simulation results to\n: \t'+os.getcwd()+'/'+self.outfile) else: print('saved simulation results to\n: \t'+self.outfile)
mbarrowBlockedHi Hugo, this is promising. I have a final confusion my side.
Each entry of the ‘position’ list is 24 elements long.
Is this to be expected? If so how can I convert to x,y,z?
Thanks
mbarrowBlockedHi Hugo, thanks for getting back to me and trying to help.
I made a modification to steak.scn but I thought it may save time to dump the steak.scn here along with the modifications.
the topology you suggested looks ok, it has position vectors and youngs modulus values which I wish to export to a vtk file if I inspect the nodes with runSofa. But the VTKExporter won’t pick up on the youngs modulus values no matter what I try and I can’t write them out.
<?xml version="1.0"?> <Node name="Root" gravity="0 -9.81 0 " dt="0.1" > <RequiredPlugin pluginName="Flexible"/> <RequiredPlugin pluginName="image"/> <VisualStyle displayFlags="showVisual showBehavior" /> <DefaultAnimationLoop /> <DefaultVisualManagerLoop /> <EulerImplicitSolver rayleighStiffness="0.1" rayleighMass="0.1" /> <CGLinearSolver template="GraphScattered" iterations="10" threshold="1e-008" /> <!-- MB demo meat params (less plausible jiggle jiggle, but do work) --> <ImageContainer name="loader" filename="data/steak-seg-highres.ppm" drawBB="false" /> <ImageFilter name="selectchannel" src="@loader" filter="21" param="0"/> <ImageFilter name="extruder" inputImage="@selectchannel.outputImage" filter="20" param="-5 -3.75 -1 64 64 15 0.15 0.15 0.15 0" inputTransform="-5 -3.75 0 0 0 0 0.025 0.025 0.8 0 1 0"/> <!--<ImageContainer name="image" image="@extruder.outputImage" transform="@extruder.outputTransform" drawBB="false"/>--> <ImageContainer name="image" image="@extruder.outputImage" transform="@extruder.outputTransform" drawBB="false"/> <TransferFunction name="youngM" template="ImageUC,ImageD" inputImage="@extruder.outputImage" param="0 0 1 20000 254 5000 255 15000000000"/> <ImageViewer template="ImageD" name="viewer" image="@youngM.outputImage" transform="@extruder.outputTransform" /> <TransferFunction name="densityTF" template="ImageUC,ImageD" inputImage="@extruder.outputImage" param="0 0 1 0.01"/> <Node name="Flexible" > <ImageSampler template="ImageUC" name="sampler" src="@../image" method="1" param="50" fixedPosition="" showSamplesScale="0"/> <MergeMeshes name="merged" nbMeshes="2" position1="@sampler.fixedPosition" position2="@sampler.position" /> <MechanicalObject template="Affine" name="dof" src="@merged" showObject="1" showObjectScale=".1"/> <VoronoiShapeFunction name="SF" template="ShapeFunctiond,ImageD" image="@../youngM.outputImage" transform="@../extruder.outputTransform" nbRef="2" method="0" bias="true" printLog="false" /> <Node name="behavior" > <ImageGaussPointSampler name="sampler" indices="@../SF.indices" weights="@../SF.weights" transform="@../SF.transform" method="2" order="1" showSamplesScale="0" printLog="1" targetNumber="200" /> <MechanicalObject template="F331" name="F" /> <!-- <MLSMapping template="Affine,F331" showDeformationGradientScale="0.1"/> --> <LinearMapping template="Affine,F331" name="Lmap" showDeformationGradientScale="0.1"/> <!-- MB swap MLS for linear --> <Node name="E" > <ImageValuesFromPositions name="youngM" position="@../sampler.position" image="@../../../youngM.outputImage" transform="@../../../extruder.outputTransform" /> <MechanicalObject template="E331" name="E" /> <CorotationalStrainMapping template="F331,E331" method="svd" geometricStiffness="1"/> <HookeForceField template="E332" name="ff" youngModulus="@youngM.values" poissonRatio="0" viscosity="0" /> <!-- MB: Broken? --> <TetrahedronSetTopologyContainer src="@youngM" name="wee" points="@youngM.values" position="@Lmap.restPosition"/> <VTKExporter filename="poo.vtu" edges="1" triangles="1" quads="1" hexas="1" tetras="1" position="@wee.position" cellsDataFields="@wee.points" pointsDataFields="@youngM.values" XMLformat="1" exportAtBegin="true" overwrite="true"/> </Node> </Node> <Node name="collision" > <MeshObjLoader name="MeshLoader" filename="data/steak.obj"/> <Mesh src="@MeshLoader" name="mesh" /> <MechanicalObject template="Vec3d" name="pts" /> <UniformMass totalMass="250" /> <BoxROI template="Vec3d" box="0 -2 0 5 2 5" position="@mesh.position" /> <RestShapeSpringsForceField template="Vec3d" points="@[-1].indices" stiffness="1E3"/> <LinearMapping template="Affine,Vec3d"/> </Node> <Node name="visual" > <OglModel template="ExtVec3f" name="Visual" fileMesh="data/steak.obj" texturename="data/steak.png" normals="0"/> <LinearMapping template="Affine,ExtVec3f"/> </Node> </Node> </Node>
mbarrowBlockedHello Hugo, I think there is indeed some kind of bug.
Position is showing the youngs modulus values in the X column of the three column position vector. Y and Z are all 0’s. This is wrong and should not be possible because I have not set position to be youngs modulus in the XML.
I need this feature to work, what are my options?
mbarrowBlockedHi Hugo, that didn’t work for me. The vtk exporter won’t populate if I don’t use a mesh as a source for point data.
I am trying to export the data created dynamically in an example .scn. Specifically
sofa/v17.12/src/applications/plugins/Flexible/examples/demos/steak.scn
I am trying to save the youngM points and corresponding rest positions, which are generated dynamically in that .scn file
So, I want to output a set of points in a vtk file for the “E” node. Here are my non-working lines of code in the “E” node of steak.scn. With this extra context, can you help?
... <Node name="E" > <ImageValuesFromPositions name="youngM" position="@../sampler.position" image="@../../../youngM.outputImage" transform="@../../../extruder.outputTransform" /> <MechanicalObject template="E332" name="E" /> <!-- <GreenStrainMapping template="F332,E332" /> --> <CorotationalStrainMapping template="F332,E332" geometricStiffness="false" method="svd" /> <HookeForceField template="E332" name="ff" youngModulus="@youngM.values" poissonRatio="0" viscosity="0" /> <PointSetTopologyContainer name="wee" src="@youngM" points="@youngM.values" /> <VTKExporter filename="poo.vtu" edges="1" position="@wee.position" pointsDataFields="@wee.points" XMLformat="1" exportAtBegin="true" overwrite="true"/> </Node>
13 August 2018 at 01:49 in reply to: [SOLVED] Can SOFA be called from my system python as part of a larger tool chain? #11653mbarrowBlockedAlthough I would still like to know the answer to the python question, I have been able to solve my problem.
I am using batch mode for -n cycles and writing the final output from a VTKExporter with XMLformat=”1″ and exportAtEnd=”1″
I can then treat these files as xml in the later part of my tool chain.
Just leaving this up in case anyone has the basic question of running the simulator for n cycles and then collecting output for processing.
26 June 2018 at 19:56 in reply to: [SOLVED] Need (very) old version of SOFA to use "Flexible" plugin. #11238mbarrowBlockedHi Hugo, thank you for being so helpful.
I would like to reproduce the results shown in This Flexible Plugin Demo.
I see the .scn files for the first few examples (up to and including the steak), but I don’t know how to generate or observe the compliance colour maps that are demonstrated. Could you provide instructions on how to reproduce the results in this demo video?
Michael
25 June 2018 at 08:59 in reply to: [SOLVED] Need (very) old version of SOFA to use "Flexible" plugin. #11233mbarrowBlockedDear Hugo
I would like to correct myself. It seems that the plugin does mostly work, its just quite hard to tell because many of the example .scn files are broken or are not super intuitive to understand for a newcomer.
Thanks,
Michael
24 June 2018 at 21:46 in reply to: [SOLVED] Need (very) old version of SOFA to use "Flexible" plugin. #11232mbarrowBlockedDear Hugo,
I don’t think the available binaries and branches are old enough. It appears to be broken in 2015 SOFA, I have tested the shapeFunction directory examples in this revision too. I have a matrix of what works and what doesn’t if you are interested.
I need a very old version that is not on the github. The code seems to be from 2012. I would guess circa 2012 or so is a good bet.
It is my intention to update the Flexible plugin, but I need known good results to validate against since the google tests pass even though the plugin is clearly broken.
Can you help?
Thanks
17 June 2018 at 06:50 in reply to: [SOLVED] What is the best way to perform 2D FEM with SOFA? #11215mbarrowBlockedPlease disregard this, I looked more carefully and found the anisotropic2DFEM.scn example.
mbarrowBlockedThank you, that is very helpful!
mbarrowBlockedThank you Hugo. Sorry I’m a beginner. Does this mean I’ve been looking at the wrong GPU-classes if I want to benchmark state of the art SOFA GPU performance or is the Implicit / Semi-Implicit code not available for general users?
Cheers,
Michael
mbarrowBlockedHi, I would like to but I’m confused about one thing. There seem to be some advanced simulators showcased on the site (Eye surgery sim, tissue tearing etc). Do these not use the CUDA TLED FEM? I would like to focus on the most state of the art implementation as the code seems complex and we want to benchmark the state of the art configuration.
Cheers!
-
AuthorPosts