Hi Roy, Below is how I create mesh, nodes, and elements:
ReplicatedMesh mesh(*comm); // create list of nodes and segments std::vector<unsigned int> nodes; std::vector<unsigned int> elems; // create two nodes at point (0,0,0) and (1,1,1) and element between these // nodes { auto add_node = mesh.add_point(Point(0., 0., 0.)); nodes.push_back(add_node->id()); add_node = mesh.add_point(Point(1., 1., 1.)); nodes.push_back(add_node->id()); auto elem = Elem::build(EDGE2).release(); elem->set_node(0) = mesh.node_ptr(nodes[0]); elem->set_node(1) = mesh.node_ptr(nodes[1]); auto add_elem = mesh.add_elem(elem); elems.push_back(add_elem->id()); // finish adding nodes and elements mesh.prepare_for_use(); } // add equation system for pressure EquationSystems eq_sys(mesh); auto &flow = eq_sys.add_system<TransientLinearImplicitSystem>("Flow"); flow.add_variable("pressure", FIRST); flow.time = 0.0; // attach initial condition flow.attach_init_function(initial_condition); // attach assembly function flow.attach_assemble_function(assemble_net); // fix value of first node (Dirichlet boundary condition) { // auto elem_0 = mesh.elem(elems[0]); // flow.get_dof_map().constrain_p_dofs(0, elem_0, 0, elem_0->level()); std::set<boundary_id_type> boundary_ids; boundary_ids.insert(0); std::vector<unsigned int> variables = {0}; ConstFunction<Number> df(2); DirichletBoundary diri_bc(boundary_ids, variables, &df); flow.get_dof_map().add_dirichlet_boundary(diri_bc); } eq_sys.init(); I am not setting boundary id of the element (can we set them?). For Dirichlet boundary condition on 1 dof, I am not sure how to put a constraint row. Regards, Prashant On Thu, Dec 5, 2019 at 12:52 PM Stogner, Roy H <royst...@ices.utexas.edu> wrote: > > On Thu, 5 Dec 2019, Prashant Kumar Jha wrote: > > > I can create a network mesh consisting of edge elements in 3D space. This > > is non-standard mesh in the sense that I start with empty mesh, add > couple > > of nodes, add edge element between nodes. Each node has 1 pressure dof. > On > > this network, I am now trying to solve 1D pde for pressure. For boundary > > conditions, I want to fix the two ends of the network (i.e. the first dof > > and the last dof) to a specific value. > > > > DirichletBoundary with boundary id 0 and 1 result in error possibly due > to > > mesh in 3D where as elements are of 1D nature. > > That shouldn't be the case. What exactly is the error? Did you set > the boundary ids when you created the mesh? > > > To get around this, I was wondering if I could fix the individual dof to > a > > specific value. Any suggestions to make above work is appreciated. > > You can manually add a constraint row for each boundary dof, or you > can use a penalty method. > --- > Roy > -- Regards, Prashant https://www.math.lsu.edu/~jha/ _______________________________________________ Libmesh-users mailing list Libmesh-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libmesh-users