From c14dea8d57ec6c46d8b0fac798bb203bca32175c Mon Sep 17 00:00:00 2001 From: andcarl384 Date: Tue, 16 Apr 2024 16:19:23 -0400 Subject: [PATCH 1/7] Assert bcid set names are different MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This solves problems found when using MOOSE in tandem with libmesh due to MOOSE’s implementation treating names as the “first-class” identifier Resolves: #3489 --- src/apps/meshbcid.C | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/apps/meshbcid.C b/src/apps/meshbcid.C index ba29e7634f..bf72e6081a 100644 --- a/src/apps/meshbcid.C +++ b/src/apps/meshbcid.C @@ -44,7 +44,7 @@ void usage_error(const char * progname) exit(1); } - +std::map bcids; int main(int argc, char ** argv) { LibMeshInit init(argc, argv); @@ -90,7 +90,20 @@ int main(int argc, char ** argv) BoundingBox normals(minpt, maxpt), points(minpt, maxpt); - + std::string side_set_name; + std::string node_set_name; + if (cl.search("--sideSetName")) + { + side_set_name = cl.next(""); + assert(bcids.find(side_set_name) == bcids.end()); + bcids.insert(std::pair (side_set_name, bcid)); + } + else if (cl.search("--nodeSetName")) + { + node_set_name = cl.next(""); + assert(bcids.find(node_set_name) == bcids.end()); + bcids.insert(std::pair (node_set_name, bcid)); + } if (cl.search("--minnormalx")) normals.min()(0) = cl.next(normals.min()(0)); if (cl.search("--maxnormalx")) From 54b6ca6b6d6ecfc0e75184beed2a8b32ad455058 Mon Sep 17 00:00:00 2001 From: andcarl384 Date: Sun, 21 Apr 2024 18:38:25 -0500 Subject: [PATCH 2/7] resizes output vector to better handle vectors enhances MeshFunction to better handle vector variables which in turn helps general field transfers work with vectors as well resolves: #3714 see also: #26084, #26045 --- include/mesh/mesh_function.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/mesh/mesh_function.h b/include/mesh/mesh_function.h index 96aadb94ca..0d063197a7 100644 --- a/include/mesh/mesh_function.h +++ b/include/mesh/mesh_function.h @@ -406,6 +406,11 @@ class MeshFunction : public FunctionBase, * See \p enable_out_of_mesh_mode() for more details. */ DenseVector _out_of_mesh_value; + + /** + * the new size to resize output to + */ + int _new_resize; }; From 8081c03a7cb97efa882d41ded1283cff4bc746a2 Mon Sep 17 00:00:00 2001 From: andcarl384 Date: Sun, 21 Apr 2024 19:05:50 -0500 Subject: [PATCH 3/7] resizes output vector to better handle vectors enhances MeshFunction to better handle vector variables which in turn helps general field transfers work with vectors as well resolves: #3714 see also: #26084, #26045 --- src/mesh/mesh_function.C | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/src/mesh/mesh_function.C b/src/mesh/mesh_function.C index 4ed06cdfe6..9a7999dc26 100644 --- a/src/mesh/mesh_function.C +++ b/src/mesh/mesh_function.C @@ -50,7 +50,8 @@ MeshFunction::MeshFunction (const EquationSystems & eqn_systems, _vector (vec), _dof_map (dof_map), _system_vars (std::move(vars)), - _out_of_mesh_mode (false) + _out_of_mesh_mode (false), + _new_resize (0) { } @@ -67,7 +68,8 @@ MeshFunction::MeshFunction (const EquationSystems & eqn_systems, _vector (vec), _dof_map (dof_map), _system_vars (1,var), - _out_of_mesh_mode (false) + _out_of_mesh_mode (false), + _new_resize (0) { } @@ -78,7 +80,8 @@ MeshFunction::MeshFunction (const MeshFunction & mf): _vector (mf._vector), _dof_map (mf._dof_map), _system_vars (mf._system_vars), - _out_of_mesh_mode (mf._out_of_mesh_mode) + _out_of_mesh_mode (mf._out_of_mesh_mode), + _new_resize (0) { // Initialize the mf and set the point locator if the // input mf had done so. @@ -118,8 +121,31 @@ void MeshFunction::init () const MeshBase & mesh = this->_eqn_systems.get_mesh(); _point_locator = mesh.sub_point_locator(); - // ready for use - this->_initialized = true; +int vec_dim = 0; +int n_vector_vars = 0; +int n_scalar_vars = 0; + +int total_variables = _dof_map.n_variables(); +const MeshBase & mesh = this->_eqn_systems.get_mesh(); +_point_locator = mesh.sub_point_locator(); + +for (int i = 0; i < total_variables; ++i) +{ + FEType fe_type = _dof_map.variable_type(i); + if (fe_type != SCALAR) + { + n_vector_vars++; + int vector_dim = FEInterface::n_vec_dim(mesh, fe_type); + if (vector_dim > vec_dim) + vec_dim = vector_dim; + } + else + n_scalar_vars++; + +} + +// ready for use +this->_initialized = true; } From add40f7997f039599201891eeb6c593272307b2b Mon Sep 17 00:00:00 2001 From: andcarl384 Date: Sun, 21 Apr 2024 19:23:34 -0500 Subject: [PATCH 4/7] fix meshbcid.C --- src/apps/meshbcid.C | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/src/apps/meshbcid.C b/src/apps/meshbcid.C index bf72e6081a..6feb034fa9 100644 --- a/src/apps/meshbcid.C +++ b/src/apps/meshbcid.C @@ -44,7 +44,7 @@ void usage_error(const char * progname) exit(1); } -std::map bcids; + int main(int argc, char ** argv) { LibMeshInit init(argc, argv); @@ -90,20 +90,7 @@ int main(int argc, char ** argv) BoundingBox normals(minpt, maxpt), points(minpt, maxpt); - std::string side_set_name; - std::string node_set_name; - if (cl.search("--sideSetName")) - { - side_set_name = cl.next(""); - assert(bcids.find(side_set_name) == bcids.end()); - bcids.insert(std::pair (side_set_name, bcid)); - } - else if (cl.search("--nodeSetName")) - { - node_set_name = cl.next(""); - assert(bcids.find(node_set_name) == bcids.end()); - bcids.insert(std::pair (node_set_name, bcid)); - } + if (cl.search("--minnormalx")) normals.min()(0) = cl.next(normals.min()(0)); if (cl.search("--maxnormalx")) @@ -225,4 +212,4 @@ int main(int argc, char ** argv) libMesh::out << "Wrote mesh " << outputname << std::endl; return 0; -} +} \ No newline at end of file From 870694593f5db374892dd64e88a05ae6ac09209a Mon Sep 17 00:00:00 2001 From: andcarl384 Date: Sun, 21 Apr 2024 19:27:08 -0500 Subject: [PATCH 5/7] fix mesh_function.h --- include/mesh/mesh_function.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mesh/mesh_function.h b/include/mesh/mesh_function.h index 0d063197a7..bd3cbd836c 100644 --- a/include/mesh/mesh_function.h +++ b/include/mesh/mesh_function.h @@ -409,7 +409,7 @@ class MeshFunction : public FunctionBase, /** * the new size to resize output to - */ + */ int _new_resize; }; From 451f7fd48b27c5c8b408d0be99c0ca0e67875a18 Mon Sep 17 00:00:00 2001 From: andcarl384 Date: Mon, 22 Apr 2024 11:18:36 -0400 Subject: [PATCH 6/7] fixed mesh_function.C --- src/mesh/mesh_function.C | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/mesh/mesh_function.C b/src/mesh/mesh_function.C index 9a7999dc26..fb9cfc9868 100644 --- a/src/mesh/mesh_function.C +++ b/src/mesh/mesh_function.C @@ -144,6 +144,8 @@ for (int i = 0; i < total_variables; ++i) } +_new_resize = vec_dim * n_vector_vars + n_scalar_vars; + // ready for use this->_initialized = true; } @@ -270,8 +272,7 @@ void MeshFunction::operator() (const Point & p, { // resize the output vector to the number of output values // that the user told us - output.resize (cast_int - (this->_system_vars.size())); + output.resize (_new_resize); { @@ -498,7 +499,7 @@ void MeshFunction::_gradient_on_elem (const Point & p, // resize the output vector to the number of output values // that the user told us - output.resize (this->_system_vars.size()); + output.resize (_new_resize); const unsigned int dim = element->dim(); @@ -615,7 +616,7 @@ void MeshFunction::hessian (const Point & p, // resize the output vector to the number of output values // that the user told us - output.resize (this->_system_vars.size()); + output.resize (_new_resize); { From f1b10f1cc4ed8aaed9e166e6896d37e5fae573e5 Mon Sep 17 00:00:00 2001 From: andcarl384 Date: Mon, 22 Apr 2024 11:21:16 -0400 Subject: [PATCH 7/7] mesh_function.C comments --- src/mesh/mesh_function.C | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/mesh/mesh_function.C b/src/mesh/mesh_function.C index fb9cfc9868..9c99001d9e 100644 --- a/src/mesh/mesh_function.C +++ b/src/mesh/mesh_function.C @@ -270,8 +270,7 @@ void MeshFunction::operator() (const Point & p, } else { - // resize the output vector to the number of output values - // that the user told us + // resize the output vector to the _new_resize output.resize (_new_resize); @@ -497,8 +496,7 @@ void MeshFunction::_gradient_on_elem (const Point & p, { libmesh_assert(element); - // resize the output vector to the number of output values - // that the user told us + // resize the output vector to the _new_resize output.resize (_new_resize); const unsigned int dim = element->dim(); @@ -614,8 +612,7 @@ void MeshFunction::hessian (const Point & p, << " are not yet implemented!" << std::endl); - // resize the output vector to the number of output values - // that the user told us + // resize the output vector to the _new_resize output.resize (_new_resize);