def _make_nodes(self) -> None: """ Generate the list of nodes """ pos = chrono.ChVectorD(*self._pos) mass = (self._mass / (self._subdiv[0] + 1) * (self._subdiv[1] + 1) * (self._subdiv[2] + 1)) # for each dimension generate the list of positions where to generate the nodes # the index of the node identify the posiion in the grid grid = [ np.linspace(0, dim, sub + 1) for dim, sub in zip(self._size, self._subdiv) ] # 3d array containing the nodes self._nodes = np.ndarray([i + 1 for i in self._subdiv], dtype=np.dtype(fea.ChNodeFEAxyz)) # iterator for self._nodes with np.nditer(self._nodes, flags=["multi_index", "refs_ok"], op_flags=["readwrite"]) as it: for i in it: ind = it.multi_index # index of the current node node_pos = chrono.ChVectorD( grid[0][ind[0]], grid[1][ind[1]], grid[2][ind[2]]) # local position of the node tmp = fea.ChNodeFEAxyz(pos + node_pos) tmp.SetMass(mass) i[...] = tmp # add the node to self._nodes self._mesh.AddNode(tmp) # add the node to the mesh
myapplication.AssetUpdateAll() mysystem.SetupInitial() # --------------------------------------------------------------------- # SIMULATION # Run the simulation # Change the solver form the default SOR to the MKL Pardiso, more precise for fea. msolver = mkl.ChSolverMKLcsm() mysystem.SetSolver(msolver) myapplication.SetTimestep(0.0001) step = 0 save_at = 2 myapplication.SetVideoframeSave(False) inf_mesh_big.AddNode(fea.ChNodeFEAxyz(chrono.ChVectorD( 100., 0., 0.))) # hack to fix issue with doStep while myapplication.GetDevice().run(): print('step', step) myapplication.BeginScene() myapplication.DrawAll() if step == save_at: myapplication.SetVideoframeSave(False) # shape.SetPos(chrono.ChVectorD(100.,0.,0.)) # hack to hide cone #if step > save_at and step < len(nodes_inf_all) + save_at: # for ring in range(N_RINGS): # nodes3d = np.reshape(nodes_inf_all[ring][step - save_at], (int(len(nodes_inf_all[ring][step - save_at]) / 3), 3)) # for n3 in nodes3d: # fn3 = fea.ChNodeFEAxyz(tool.make_ChVectorD(n3)) # inf_mesh.AddNode(fn3)
#-COORDFlex are the initial coordinates for each node, # the first three are the position COORDFlex[i, 0] = (i % (numDiv_x + 1)) * dx COORDFlex[i, 1] = (i / (numDiv_x + 1)) % (numDiv_y + 1) * dy COORDFlex[i, 2] = (i) / ((numDiv_x + 1) * (numDiv_y + 1)) * dz #-VELCYFlex is essentially the same as COORDFlex, but for the initial # velocity instead of position. # let's assume zero initial velocity for nodes VELCYFlex[i, 0] = 0 VELCYFlex[i, 1] = 0 VELCYFlex[i, 2] = 0 # Adding the nodes to the mesh i = 0 while i < TotalNumNodes: node = fea.ChNodeFEAxyz( chrono.ChVectorD(COORDFlex[i, 0], COORDFlex[i, 1], COORDFlex[i, 2])) node.SetMass(0.0) my_mesh.AddNode(node) if (NDR[i, 0] == 1 and NDR[i, 1] == 1 and NDR[i, 2] == 1): node.SetFixed(True) i += 1 nodetip = fea.CastToChNodeFEAxyz( fea.CastToChNodeFEAbase(my_mesh.GetNode(TotalNumNodes - 1))) elemcount = 0 while elemcount < TotalNumElements: element = fea.ChElementBrick() InertFlexVec = chrono.ChVectorD( ElemLengthXY[elemcount, 0], ElemLengthXY[elemcount, 1],
""" CANNOT INSTANTIATE TEMPLATE Example 4 and 5 in C++ equivalent demo require respectively ChLoad<MyLoaderTriangular> and ChLoad<MyLoaderPointStiff>(mnodeC) """ # Example 6: # As before, create a custom load with stiff force, acting on a single node, but # this time we inherit directly from ChLoadCustom, i.e. a load that does not require ChLoader features. # This is mostly used in case one does not need the automatic surface/volume quadrature of ChLoader. # As a stiff load, this will automatically generate a jacobian (tangent stiffness matrix K) # that will be used in statics, implicit integrators, etc. mnodeD = fea.ChNodeFEAxyz(chrono.ChVectorD(2, 10, 3)) my_mesh.AddNode(mnodeD) class MyLoadCustom(chrono.ChLoadCustom): def __init__(self, mloadable): chrono.ChLoadCustom.__init__(self, mloadable) #/ "Virtual" copy constructor (covariant return type). def Clone(self): newinst = copy.deepcopy(self) return newinst # Compute Q=Q(x,v) # This is the function that you have to implement. It should return the generalized Q load # (i.e.the force in generalized lagrangian coordinates). # For ChNodeFEAxyz, Q loads are expected as 3-rows vectors, containing absolute force x,y,z. # As this is a stiff force field, dependency from state_x and state_y must be considered.
os.mkdir(out_dir) # Create a Chrono::Engine physical system my_system = chrono.ChSystemSMC() # Create a mesh, that is a container for groups # of elements and their referenced nodes. my_mesh = fea.ChMesh() # Remember to add the mesh to the system! my_system.Add(my_mesh) # my_system.Set_G_acc(VNULL) or #my_mesh.SetAutomaticGravity(False) nodePlotA = fea.ChNodeFEAxyz() nodePlotB = fea.ChNodeFEAxyz() nodesLoad = [] # std::vector<std::shared_ptr<ChNodeFEAxyz>> ref_X = chrono.ChFunction_Recorder() ref_Y = chrono.ChFunction_Recorder() load_force = chrono.ChVectorD() # # BENCHMARK n.1 # # Add a single BST element: # if (False): # set as 'true' to execute this