From: Yuxiang W. <yw...@vi...> - 2018-11-08 16:38:48
|
Ah - thank you for the hint! Totally my bad. I accidentally put L2_LAGRANGE while the element should really be LAGRANGE. That makes perfect sense now. I have attached my main function just in case someone else in the future may find this reference. Thank you so much Roy! Best, Shawn // Begin the main program. int main (int argc, char ** argv) { // Initialize libMesh. LibMeshInit init (argc, argv); Mesh mesh(init.comm(), 3); MeshTools::Generation::build_square (mesh, 2, 2, -1., 1., -1., 1., QUAD4); mesh.set_spatial_dimension (3); EquationSystems equation_systems (mesh); ExplicitSystem & director_system = equation_systems.add_system<ExplicitSystem> ("DirectorSystem"); director_system.add_variable("Vnx", FIRST, LAGRANGE); director_system.add_variable("Vny", FIRST, L2_LAGRANGE); equation_systems.init (); // Use an explicit system to store nodal directors const unsigned int director_system_id = director_system.number(); for (auto node : mesh.node_ptr_range()) { std::cout << node->n_comp(director_system_id, 0) << std::endl; std::cout << node->n_comp(director_system_id, 1) << std::endl; } return 0; } And the output: ./example-dbg 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 On Thu, Nov 8, 2018 at 6:13 AM Stogner, Roy H <roy...@ic...> wrote: > > On Thu, 8 Nov 2018, Yuxiang Wang wrote: > > > Sorry for the naive question. In short, I have a system with three > > variables (first order Lagrangian elements). I thought that for each of > the > > node in the mesh, it would have a DOF attached to it with n_comp==1. > > However, when I used the following code snippet to check, the n_comp is > > actually 0 (not 1). > > > > for (auto node : mesh.node_ptr_range()) > > std::cout << node->n_comp(0, 0) << std::endl; > > > > What I was trying to achieve is to iterate through all the nodes, and > > assign solution values to each variable DOF attached to the node from a > > Eigen::Vector3d. Then I got the error message about: > > > > Assertion `comp < this->n_comp(s,var)' failed. > > comp = 0 > > this->n_comp(s,var) = 0 > > > > Any help would be appreciated. Thank you! > > Are you on a mesh with only first-order geometric elements? If not > then the higher-order nodes (e.g. the mid-edge nodes on a TRI6) will > have n_comp == 0 for first-order Lagrange variables. > --- > Roy > -- Yuxiang "Shawn" Wang, PhD yw...@vi... +1 (434) 284-0836 |