
jjcasmar replied to the topic Implement our own LinearSolver in the forum Programming with SOFA 8 months, 2 weeks ago
I have kind of solve this. I have reimplemented the CG solver using the one in Caribou. Based on that, I have kept only the implementation that doesn’t build the matrix, but added some calls to assemble the vector that I had to project after preconditioning according to the paper linked above.
I copy paste the implementation here, and when I…[Read more]

jjcasmar replied to the topic Implement our own LinearSolver in the forum Programming with SOFA 8 months, 3 weeks ago
I have been looking at the code from Caribou, as well as the code from ShewchukPCGLinearSolver and I have posted a possible bug on the github tracker. If I understand the code correctly, there are some differences with the algorithm described in https://www.cs.ubc.ca/~ascher/papers/ab.pdf
When I have that clear, I will have a better look on how…[Read more]

jjcasmar started the topic Implement our own LinearSolver in the forum Programming with SOFA 8 months, 3 weeks ago
I want to implement my own linear solver for using it as a preconditioner with the ShewchukPCGLinearSolver. My solver is pretty simple, is just a diagonal matrix which I have as an Eigen::DiagonalMatrix.
The LinearSolver API provides 3 functions which I think I need to use:
`
/// Set the linear system righthand term vector, from the values…[Read more] 
jjcasmar replied to the topic Non linear implicit solver in the forum Programming with SOFA 1 year, 2 months ago
I think this solves all the issue.
I think you did a small typo in
root.object2.mo.position += root.object1.mo.dx
right? 
jjcasmar replied to the topic Non linear implicit solver in the forum Programming with SOFA 1 year, 2 months ago
I think I still have one doubt.
From Caribou
`
// Updating the geometry
x.peq(dx); // x := x + dx// Solving constraints
// Calls “solveConstraint” method of every ConstraintSolver objects found in the current context tree.
// todo(jnbrunet): Shouldn’t this be done AFTER the position propagation of the…[Read more] 
jjcasmar replied to the topic Compute forces programatically in the forum Programming with SOFA 1 year, 2 months ago
So I still need to update the mapping to propagate the positions, right?

jjcasmar replied to the topic Non linear implicit solver in the forum Programming with SOFA 1 year, 2 months ago
Great, that is what I was looking for.
So if I understand correctly,
1) Compute forces and current error to bootstrap the solver
2) Compute a dx
3) Compute x as x0 + dx
4) Propagate this changes through the graph usingMechanicalPropagateOnlyPositionAndVelocityVisitor
5) Recompute forces, now in the new state
6) RepeaSomewhere between 4 and 5,…[Read more]

jjcasmar replied to the topic Compute forces programatically in the forum Programming with SOFA 1 year, 2 months ago
the
mop.computeForce
takes care of updating the mappings in both directions? 
jjcasmar started the topic Compute forces programatically in the forum Programming with SOFA 1 year, 2 months ago
I want to debug some forces on the initial state of the simulation. What I am doing right now is set the dt to 0 and do a step, that way the correct visitors are launched and the forces are computed, but looks like a hack.
What is the correct way to ask SOFA to compute force? I guess that I will also need to apply mappings before computing…[Read more]

jjcasmar started the topic Non linear implicit solver in the forum Programming with SOFA 1 year, 2 months ago
I have looked at the EulerImplicitSolver and it only does a Newton step integration. I am trying to implement a version of it doing several Newton steps for integrating more complex energies and systems but I am stuck on the design of it.
Normally, when I do this kind of solvers outside of SOFA, I implement a solve very similar to what…[Read more]

jjcasmar replied to the topic Doubts about how ForceField and mapping interact in the forum Programming with SOFA 1 year, 3 months ago
Sorry, cant share the scene description right now. Ill do it ASAP.
One thing I normally dont have clear if is I have to add the kFactor or dt on the computations and also the sign of the result.
For example, if used in a EulerImplicit solver, the force is multiplied by the dt and the hessian is multiplied by dt+beta value (or something like…[Read more]

jjcasmar replied to the topic Adding new template for MechanicalObject in the forum Programming with SOFA 1 year, 3 months ago
@Froy can you provide a bit more details or documentation on how to do this? I am trying to mimic what I see in other types, but I fail to actually make it work. I am having linking errors when I try to load my plugin.
[Read more]
[ERROR] [PluginManager] Plugin loading failed (/home/jjcasmar/projects/VNCSSofaPlugin/build/Debug/lib/libVNCSSofaPlugin.so):… 
jjcasmar started the topic Doubts about how ForceField and mapping interact in the forum Programming with SOFA 1 year, 3 months ago
I am implementing a Mapping that, given my degress of freedom, computes the deformation gradient. Then I have an energy that depends on the deformation gradient. With this scheme, I have some doubts.
First of all, the math for this scheme would be
`
u = DoF
F = g(u) // Deformation gradient is a function of the DoF
E = e(F) // Energy is a…[Read more] 
jjcasmar started the topic Unable to assign rest_position to MO in SofaPython3 plugin in Debug mode in the forum Programming with SOFA 1 year, 3 months ago
I have compiled SOFA and SofaPython3 plugni in debug mode. In this scenario, I try to assign a numpy vector to the rest position of a mechanical object, but it fails. This is the python code I am executing:
`
xNObject = coarseObject.addChild(“xN”)
xN_mo = xNObject.addObject(“MechanicalObject”, template=”Vec1″, name=”xN_MO”)…[Read more] 
jjcasmar started the topic Adding new template for MechanicalObject in the forum Programming with SOFA 1 year, 4 months ago
I want to replicate some of the functionality in Flexible plugin, and since I havent been able to make it work properly, I am trying to add some stuff of my own. In particular, I want to add a new template for deformation gradient types (3×3, 3×2, 2×2 and 1×1 matrices) but I am not sure how to create the types so that I can do a…[Read more]

jjcasmar replied to the topic Use Eigen::SparseMatrix in SofaPython3 in the forum Programming with SOFA 1 year, 4 months ago
Thanks for the answer. I guess I will wait until that is ready and code that part in C++ for now.

jjcasmar started the topic Use Eigen::SparseMatrix in SofaPython3 in the forum Programming with SOFA 1 year, 4 months ago
Hi,
I want to use Eigen::SparseMatrix in SofaPython3 and provide it as a scipy csr sparse matrix but SOFA fails to convert it with the following error:
`
[ERROR] [SofaPython3::SceneLoader] RuntimeError: Trying to set the value of the data C, but the later hasn’t register it’s DataTypeInfo (see sofa/defaulttype/DataTypeInfo.h for more…[Read more] 
jjcasmar replied to the topic Preconditioner for an iterative solver in the forum Using SOFA 1 year, 7 months ago
Well, that depends on your preconditioner. For my particular use case, the preconditioned can be represented as a matrix, but its easier to represent it as some functions, kind of matrixfree preconditioner. I think saying that a its based on a external linear direct solver may arise to some misconceptions later. Better to just say that is has to…[Read more]

jjcasmar replied to the topic Preconditioner for an iterative solver in the forum Using SOFA 1 year, 7 months ago
Thanks Hugo. I have read the document you proposed and I think that this:
The ShewchukPCGLinearSolver allows to choose the preconditioner of our choice based on an external direct linear solver: LULinearSolver, SparseLDLSolver, etc
Is not exactly correct.From reading the source code, I think any linear solver can be used, not only direct linear…[Read more]

jjcasmar replied to the topic Preconditioner for an iterative solver in the forum Using SOFA 1 year, 7 months ago
So ShewchukPCGSolver is a preconditioned conjugate gradient implementation. Why is not the default CG implementation? Seems like it is a bit hidden…
If I understand correctly, I just need to provide an implementation of my preconditioner, deriving it from
sofa::core::behavior::LinearSolver
and link it to the preconditioners property, right?  Load More