use of artisynth.core.femmodels.FemModel3d in project artisynth_core by artisynth.
the class JointedFemBeams method addFem.
// create an FEM beam with specified size and stiffness, and add it
// to a mech model
private FemModel3d addFem(MechModel mech, double wx, double wy, double wz, double stiffness) {
FemModel3d fem = FemFactory.createHexGrid(null, wx, wy, wz, 10, 1, 1);
fem.setMaterial(new LinearMaterial(stiffness, 0.3));
fem.setDensity(1.0);
fem.setMassDamping(1.0);
RenderProps.setFaceColor(fem, myLinkColor);
RenderProps.setEdgeColor(fem, myEdgeColor);
fem.setSurfaceRendering(FemModel3d.SurfaceRender.Shaded);
mech.addModel(fem);
return fem;
}
use of artisynth.core.femmodels.FemModel3d in project artisynth_core by artisynth.
the class TransverseIsotropyTest method createCylinder.
FemModel3d createCylinder(double h, double r) {
FemModel3d fem = FemFactory.createCylinder(null, h, r, 24, 40, 4);
fem.setDensity(1000);
fem.setSurfaceRendering(SurfaceRender.Shaded);
RenderProps.setFaceColor(fem, Color.ORANGE);
RenderProps.setVisible(fem.getElements(), false);
double eps = 1e-10;
for (FemNode3d node : fem.getNodes()) {
if (node.getPosition().z < -h / 2 + eps) {
node.setDynamic(false);
}
}
return fem;
}
use of artisynth.core.femmodels.FemModel3d in project artisynth_core by artisynth.
the class FemBeam method build.
public void build(String[] args) throws IOException {
// Create and add MechModel
mech = new MechModel("mech");
addModel(mech);
// Create and add FemModel
fem = new FemModel3d("fem");
mech.add(fem);
// Build hex beam using factory method
FemFactory.createHexGrid(fem, length, width, width, /*nx=*/
6, /*ny=*/
3, /*nz=*/
3);
// Set FEM properties
fem.setDensity(density);
fem.setParticleDamping(0.1);
fem.setMaterial(new LinearMaterial(4000, 0.33));
// Fix left-hand nodes for boundary condition
for (FemNode3d n : fem.getNodes()) {
if (n.getPosition().x <= -length / 2 + EPS) {
n.setDynamic(false);
}
}
// Set rendering properties
setRenderProps(fem);
}
use of artisynth.core.femmodels.FemModel3d in project artisynth_core by artisynth.
the class FemModel3dEditor method addActions.
public void addActions(EditActionMap actions, SelectionManager selManager) {
LinkedList<ModelComponent> selection = selManager.getCurrentSelection();
if (containsSingleSelection(selection, FemModel3d.class)) {
FemModel3d model = (FemModel3d) selection.get(0);
actions.add(this, "Add FemMarkers ...", EXCLUSIVE);
actions.add(this, "Rebuild surface mesh");
actions.add(this, "Add new surface mesh");
actions.add(this, "Save surface mesh ...");
actions.add(this, "Save mesh as Ansys file...");
if (model.getGrandParent() instanceof MechModel) {
actions.add(this, "Attach particles ...", EXCLUSIVE);
}
} else if (containsMultipleCommonParentSelection(selection, HexElement.class)) {
actions.add(this, "Subdivide elements");
}
if (containsMultipleCommonParentSelection(selection, FemElement3d.class)) {
actions.add(this, "Rebuild surface mesh for selected elements");
actions.add(this, "Add new surface mesh for selected elements");
}
}
use of artisynth.core.femmodels.FemModel3d in project artisynth_core by artisynth.
the class Fem3dBlock method setConnected.
public synchronized void setConnected(boolean connect) {
MechModel mechMod = (MechModel) findComponent("models/mech");
if (mechMod != null) {
FemModel3d femMod = (FemModel3d) mechMod.findComponent("models/fem");
LinkedList<FemNode3d> rightNodes = new LinkedList<FemNode3d>();
for (int i = 0; i < myAttachNodes.length; i++) {
rightNodes.add(myAttachNodes[i]);
}
if (connect && !rightNodes.get(0).isAttached()) {
RigidBody rightBody = (RigidBody) mechMod.findComponent("rigidBodies/rightBody");
// position the block so that it lies at the current
// end of the beam
Plane plane = new Plane();
Point3d centroid = new Point3d();
int numPnts = rightNodes.size();
Point3d[] pnts = new Point3d[numPnts];
for (int i = 0; i < numPnts; i++) {
pnts[i] = rightNodes.get(i).getPosition();
centroid.add(pnts[i]);
}
centroid.scale(1 / (double) numPnts);
plane.fit(pnts, numPnts);
Vector3d normal = new Vector3d(plane.getNormal());
// to determine the appropriate sign of the normal
for (FemNode3d node : femMod.getNodes()) {
if (!rightNodes.contains(node)) {
Vector3d diff = new Vector3d();
diff.sub(node.getPosition(), rightNodes.get(0).getPosition());
if (diff.dot(normal) > 0) {
normal.negate();
}
break;
}
}
RigidTransform3d X = new RigidTransform3d();
X.R.setZDirection(normal);
X.R.mulAxisAngle(0, 1, 0, -Math.PI / 2);
X.p.set(centroid);
X.mulXyz(0.05, 0, 0);
rightBody.setPose(X);
rightBody.setVelocity(new Twist());
for (FemNode3d n : rightNodes) {
mechMod.attachPoint(n, rightBody);
}
} else if (!connect && rightNodes.get(0).isAttached()) {
for (FemNode3d n : rightNodes) {
mechMod.detachPoint(n);
}
}
}
myConnectedP = connect;
}
Aggregations