mor.reduction.reduceModel.ReduceModel

class ReduceModel(originalScene, nodeToReduce, listObjToAnimate, tolModes, tolGIE, outputDir, packageName='myReducedModel', addToLib=False, verbose=False, addRigidBodyModes=False, nbrCPU=4, phaseToSave=None, saveVelocitySnapshots=None, listPathToAnimation=[])[source]

Bases: object

Main class that will perform the reduction

argument

type

definition

originalScene

str

absolute path to original scene

nodeToReduce

str

Paths to models to reduce

listObjToAnimate

list(ObjToAnimate)

list conaining all the ObjToAnimate that will be use to shake our model

tolModes

float

tolerance applied to choose the modes

tolGIE

float

tolerance applied to calculated GIE

outputDir

str

absolute path to output directiry in which all results will be stored

packageName

str

Which name will have the final componant ( & package if the option addToLib is activated)

addToLib

Bool

If True will add in the python library of this plugin the finalized reduced component

verbose

Bool

display more or less verbose

addRigidBodyModes

list(int)

List of 3 of 0/1 that will allow translation along [x,y,z] axis of our reduced model

nbrCPU

int

Number of CPU we will use to generate/calculate the reduced model

phaseToSave

list(int)

List of 0/1 indicating during which phase to save the elements/X0 by default will save during first phase

Methods

generateTestScene

performReduction

Perform all the steps of the reduction in one function

phase1

The step will launch in parallel multiple Sofa scene (nbrCPU by nbrCPU number of scene) until it has run all the scene in the sequence.

phase2

With the previous result obtain in during :meth:`phase1` we compute the modes

phase3

This step will launch in parallel multiple Sofa scene (nbrCPU by nbrCPU number of scene) until it has run all the scene in the sequence.

phase4

The final step will gather all the results in 1 folder and build a reusable scene from it

setListSofaScene

Will generate a list containing dictionnaries, where each dictionnary is a set of argument for the execution of one SOFA scene.

setListSofaScene(phasesToExecute=None, phase=None)[source]

Will generate a list containing dictionnaries, where each dictionnary is a set of argument for the execution of one SOFA scene.

argument

type

definition

phasesToExecute

list(int)

Allow to choose which phase to execute for the reduction

by default will select all the phase

The number of dictionnaries generated depend upon either the number of action possibility (self.reductionAnimations.nbPossibility) or you can give with phasesToExecute specifically which possibility you want to execute.

example :

You have 2 ObjToAnimate (thing that will be animated during the execution). From self.reductionAnimations you will have 2^2 possibilities:

[0,0] | [0,1] | [1,0] | [1,1] –> where 0 mean no animation & 1 animation

  • if you give no argument, phasesToExecute = [0,1,2,3]

    it will execute possibilty 0,1,2 & 3

  • if you give phasesToExecute=[1,3]

    it will execute possibility 1 & 3

performReduction(phasesToExecute=None, nbrOfModes=None)[source]

Perform all the steps of the reduction in one function

argument

type

definition

phasesToExecute

list(int)

Allow to choose which phase to execute for the reduction
more details see setListSofaScene

nbrOfModes

int

Number of modes you want to keep
by default will keep them all

If you are sure of all the parameters this way is recommended to gain time

phase1(phasesToExecute=None)[source]

The step will launch in parallel multiple Sofa scene (nbrCPU by nbrCPU number of scene) until it has run all the scene in the sequence.

argument

type

definition

phasesToExecute

list(int)

Allow to choose which phase to execute for the reduction
more details see setListSofaScene

To run the SOFA scene in parallele we use the sofa launcher utility

What does it do to each scene:

  • Add animation to each ObjToAnimate we want for our model in the predifined sequence

  • Add a componant to save the shaking resulting states (WriteState)

  • Take all the resulting states files and combines them in one file put in the debug dir with a debug scene

phase2()[source]

With the previous result obtain in during :meth:`phase1` we compute the modes

See ReadStateFilesAndComputeModes for the way the modes are determined.

It will set nbrOfModes to its maximum, but it can be changed has argument to the next step : phase3

phase3(phasesToExecute=None, nbrOfModes=None)[source]

This step will launch in parallel multiple Sofa scene (nbrCPU by nbrCPU number of scene) until it has run all the scene in the sequence.

argument

type

definition

phasesToExecute

list(int)

Allow to choose which phase to execute for the reduction
more details see setListSofaScene

nbrOfModes

int

Number of modes you want to keep
by default will keep them all

To run the SOFA scene in parallele we use the sofa launcher utility

What does it do to each scene:

  • Take the previous one and add the model order reduction component:
    • HyperReducedFEMForceField

    • MappedMatrixForceFieldAndMas

    • ModelOrderReductionMapping

  • Produce an Hyper Reduced description of the model

  • Produce files listing the different element to keep

  • Take all the resulting states files and combines them in one file put in the debug dir with a debug scene

phase4(nbrOfModes=None)[source]

The final step will gather all the results in 1 folder and build a reusable scene from it

argument

type

definition

nbrOfModes

int

Number of modes you want to keep
by default will keep them all

Final step :