use of artisynth.core.femmodels.FemNode3d in project artisynth_core by artisynth.
the class JointedFemBeams method build.
public void build(String[] args) {
MechModel mech = new MechModel("mechMod");
addModel(mech);
double stiffness = 5000;
// create first fem beam and fix the leftmost nodes
FemModel3d fem1 = addFem(mech, 2.4, 0.6, 0.4, stiffness);
for (FemNode3d n : fem1.getNodes()) {
if (n.getPosition().x <= -1.2) {
n.setDynamic(false);
}
}
// create the second fem beam and shift it 1.5 to the right
FemModel3d fem2 = addFem(mech, 2.4, 0.4, 0.4, 0.1 * stiffness);
fem2.transformGeometry(new RigidTransform3d(1.5, 0, 0));
// create a slotted revolute joint that connects the two fem beams
RigidTransform3d TDW = new RigidTransform3d(0.5, 0, 0, 0, 0, Math.PI / 2);
SlottedRevoluteJoint joint = new SlottedRevoluteJoint(fem2, fem1, TDW);
mech.addBodyConnector(joint);
// set ranges and rendering properties for the joint
joint.setAxisLength(0.8);
joint.setMinX(-0.5);
joint.setMaxX(0.5);
joint.setSlotWidth(0.61);
RenderProps.setLineColor(joint, myJointColor);
RenderProps.setLineWidth(joint, 3);
RenderProps.setLineRadius(joint, 0.04);
}
use of artisynth.core.femmodels.FemNode3d in project artisynth_core by artisynth.
the class FemDisplayProbe method getStrainValue.
// computes strain of a point inside the model based on FEM shape
// function interpolation
private static double getStrainValue(Point3d pnt, FemModel3d model) {
Point3d loc = new Point3d();
FemElement3d elem = model.findNearestElement(loc, pnt);
Vector3d coords = new Vector3d();
double strain = 0;
if (elem != null) {
elem.getNaturalCoordinates(coords, pnt);
FemNode3d[] nodes = elem.getNodes();
for (int i = 0; i < elem.numNodes(); i++) {
strain += elem.getN(i, coords) * nodes[i].getVonMisesStrain();
}
}
return strain;
}
use of artisynth.core.femmodels.FemNode3d in project artisynth_core by artisynth.
the class MFreeFactory method createPartitionedElementsFromPoints.
private static <A extends MFreePoint3d> ArrayList<MFreeElement3d> createPartitionedElementsFromPoints(A[] pnts, HashMap<A, MFreeElement3d> pntMap) {
ArrayList<MFreeElement3d> elems = new ArrayList<MFreeElement3d>();
HashMap<FemNode3d, LinkedList<MFreeElement3d>> elemMap = new HashMap<>();
MFreeShapeFunction fun = new MLSShapeFunction();
for (A pnt : pnts) {
FemNode3d[] nodes = pnt.getDependentNodes();
MFreeElement3d elem = findElem(nodes, elemMap);
if (elem == null) {
elem = new MFreeElement3d(fun, Arrays.copyOf(nodes, nodes.length));
elems.add(elem);
for (FemNode3d node : nodes) {
LinkedList<MFreeElement3d> elemList = elemMap.get(node);
if (elemList == null) {
elemList = new LinkedList<>();
elemList.add(elem);
elemMap.put(node, elemList);
} else {
elemList.add(elem);
}
}
}
pntMap.put(pnt, elem);
}
return elems;
}
use of artisynth.core.femmodels.FemNode3d in project artisynth_core by artisynth.
the class MFreeModel3d method addMarker.
/**
* Adds a marker to this FemModel. The element to which it belongs is
* determined automatically. If the marker's current position does not lie
* within the model and {@code project == true}, it will be projected onto
* the model's surface.
*
* @param pos
* position to place a marker in the model
*/
public FemMarker addMarker(Point3d pos) {
FemMarker mkr = new FemMarker();
Point3d coord = new Point3d();
VectorNd N = new VectorNd();
FemNode3d[] nodes = findNaturalCoordinates(pos, coord, N);
mkr.setPosition(pos);
double[] wgts = new double[N.size()];
for (int i = 0; i < N.size(); ++i) {
wgts[i] = N.get(i);
}
mkr.setFromNodes(nodes, wgts);
addMarker(mkr);
return mkr;
}
use of artisynth.core.femmodels.FemNode3d in project artisynth_core by artisynth.
the class MFreeModel3d method findDependentNodesAtRest.
/**
* Finds nodes containing the given point at rest
* @param pnt point to find nodes for
* @param out output list of nodes influencing region
* @return number of nodes found
*/
public int findDependentNodesAtRest(Point3d pnt, List<FemNode3d> out) {
AABBTree nodeTree = myRestNodeTree;
if (nodeTree == null) {
nodeTree = buildRestNodeTree(myNodes);
myRestNodeTree = nodeTree;
}
ArrayList<BVNode> bvNodes = new ArrayList<BVNode>(16);
nodeTree.intersectPoint(bvNodes, pnt);
if (bvNodes.size() == 0) {
return 0;
}
int count = 0;
for (BVNode n : bvNodes) {
Boundable[] elements = n.getElements();
for (int i = 0; i < elements.length; i++) {
RestNode rnode = (RestNode) elements[i];
FemNode3d node = rnode.getNode();
if (((MFreeNode3d) node).isInDomain(pnt, 0)) {
out.add(node);
++count;
}
}
}
return count;
}
Aggregations