use of artisynth.core.femmodels.IntegrationData3d in project artisynth_core by artisynth.
the class MFreeModel3d method computeJacobianAndGradient.
private void computeJacobianAndGradient(FemElement3d region) {
IntegrationPoint3d[] ipnts = region.getIntegrationPoints();
IntegrationData3d[] idata = region.getIntegrationData();
region.setInverted(false);
for (int i = 0; i < ipnts.length; i++) {
IntegrationPoint3d ipnt = ipnts[i];
IntegrationData3d idat = idata[i];
ipnt.computeJacobianAndGradient(region.getNodes(), idat.getInvJ0());
double detJ = ipnt.computeInverseJacobian();
if (detJ < myMinDetJ) {
myMinDetJ = detJ;
myMinDetJElement = region;
}
if (detJ <= 0) {
region.setInverted(true);
myNumInverted++;
}
}
}
use of artisynth.core.femmodels.IntegrationData3d in project artisynth_core by artisynth.
the class MFreeMuscleModel method renderElementDirection.
protected void renderElementDirection(Renderer renderer, RenderProps props, FemElement3d elem, float[] coords0, float[] coords1, Matrix3d F, Vector3d dir, double len) {
IntegrationData3d[] idata = elem.getIntegrationData();
elem.computeRenderCoordsAndGradient(F, coords0);
int ndirs = 0;
dir.setZero();
for (int i = 0; i < idata.length; i++) {
Matrix3d Frame = idata[i].getFrame();
if (Frame != null) {
dir.x += Frame.m00;
dir.y += Frame.m10;
dir.z += Frame.m20;
ndirs++;
}
}
if (ndirs > 0) {
dir.normalize();
F.mul(dir, dir);
dir.scale(len);
coords0[0] -= (float) dir.x / 2;
coords0[1] -= (float) dir.y / 2;
coords0[2] -= (float) dir.z / 2;
coords1[0] = coords0[0] + (float) dir.x;
coords1[1] = coords0[1] + (float) dir.y;
coords1[2] = coords0[2] + (float) dir.z;
props.getLineColor(myDirectionColor);
renderer.drawLine(props, coords0, coords1, myDirectionColor, /*capped=*/
false, /*highlight=*/
false);
}
}
use of artisynth.core.femmodels.IntegrationData3d in project artisynth_core by artisynth.
the class MFreeElement3d method isInvertedAtRest.
public boolean isInvertedAtRest() {
MFreeIntegrationPoint3d[] ipnts = getIntegrationPoints();
IntegrationData3d[] idata = getIntegrationData();
for (int i = 0; i < ipnts.length; i++) {
MFreeIntegrationPoint3d ipnt = ipnts[i];
IntegrationData3d idat = idata[i];
ipnt.computeJacobianAndGradient(idat.getInvJ0());
if (ipnt.getDetF() < 0) {
return true;
}
}
return false;
}
use of artisynth.core.femmodels.IntegrationData3d in project artisynth_core by artisynth.
the class MFreeElement3d method setIntegrationPoints.
public void setIntegrationPoints(ArrayList<MFreeIntegrationPoint3d> points, ArrayList<IntegrationData3d> data) {
myIntegrationPoints = new DynamicArray<>(MFreeIntegrationPoint3d.class, points.size());
for (int i = 0; i < points.size(); i++) {
IntegrationData3d idata = null;
if (data != null) {
idata = data.get(i);
}
addIntegrationPoint(points.get(i), idata, points.get(i).getWeight(), false);
}
updateAllVolumes();
myNodalExtrapolationMatrix = null;
}
use of artisynth.core.femmodels.IntegrationData3d in project artisynth_core by artisynth.
the class MFreeFactory method distributeIPointsFromMap.
// public static void distributePairedIPoints(MFreeElement3d[] elemList,
// MFreeIntegrationPoint3d[] ipnts,
// IntegrationData3d[] idata, BVTree elemTree, double tol) {
//
// for (int i = 0; i < ipnts.length; i++) {
// MFreeIntegrationPoint3d ipnt = ipnts[i];
// IntegrationData3d idat = null;
// if (idata != null) {
// idat = idata[i];
// } else {
// idat = new IntegrationData3d();
// idat.setRestInverseJacobian(new Matrix3d(Matrix3d.IDENTITY), 1);
// }
//
// ArrayList<MFreeElement3d> celems =
// findPairedElementsContaining(ipnt.getPosition(), elemTree, tol);
// for (MFreeElement3d elem : celems) {
// elem.addIntegrationPoint(ipnt, idat, ipnt.getWeight(), false);
// }
// }
//
// for (MFreeElement3d elem : elemList) {
// elem.updateAllVolumes();
// }
//
// }
private static void distributeIPointsFromMap(HashMap<MFreeIntegrationPoint3d, MFreeElement3d> pntMap) {
for (MFreeIntegrationPoint3d ipnt : pntMap.keySet()) {
IntegrationData3d idat = new IntegrationData3d();
idat.setRestInverseJacobian(new Matrix3d(Matrix3d.IDENTITY), 1);
MFreeElement3d elem = pntMap.get(ipnt);
elem.addIntegrationPoint(ipnt, idat, ipnt.getWeight(), false);
}
for (MFreeElement3d elem : pntMap.values()) {
elem.updateAllVolumes();
}
}
Aggregations