Skip to content

Commit 8081c03

Browse files
committed
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: libMesh#3714 see also: #26084, #26045
1 parent 54b6ca6 commit 8081c03

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

src/mesh/mesh_function.C

+31-5
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ MeshFunction::MeshFunction (const EquationSystems & eqn_systems,
5050
_vector (vec),
5151
_dof_map (dof_map),
5252
_system_vars (std::move(vars)),
53-
_out_of_mesh_mode (false)
53+
_out_of_mesh_mode (false),
54+
_new_resize (0)
5455
{
5556
}
5657

@@ -67,7 +68,8 @@ MeshFunction::MeshFunction (const EquationSystems & eqn_systems,
6768
_vector (vec),
6869
_dof_map (dof_map),
6970
_system_vars (1,var),
70-
_out_of_mesh_mode (false)
71+
_out_of_mesh_mode (false),
72+
_new_resize (0)
7173
{
7274
}
7375

@@ -78,7 +80,8 @@ MeshFunction::MeshFunction (const MeshFunction & mf):
7880
_vector (mf._vector),
7981
_dof_map (mf._dof_map),
8082
_system_vars (mf._system_vars),
81-
_out_of_mesh_mode (mf._out_of_mesh_mode)
83+
_out_of_mesh_mode (mf._out_of_mesh_mode),
84+
_new_resize (0)
8285
{
8386
// Initialize the mf and set the point locator if the
8487
// input mf had done so.
@@ -118,8 +121,31 @@ void MeshFunction::init ()
118121
const MeshBase & mesh = this->_eqn_systems.get_mesh();
119122
_point_locator = mesh.sub_point_locator();
120123

121-
// ready for use
122-
this->_initialized = true;
124+
int vec_dim = 0;
125+
int n_vector_vars = 0;
126+
int n_scalar_vars = 0;
127+
128+
int total_variables = _dof_map.n_variables();
129+
const MeshBase & mesh = this->_eqn_systems.get_mesh();
130+
_point_locator = mesh.sub_point_locator();
131+
132+
for (int i = 0; i < total_variables; ++i)
133+
{
134+
FEType fe_type = _dof_map.variable_type(i);
135+
if (fe_type != SCALAR)
136+
{
137+
n_vector_vars++;
138+
int vector_dim = FEInterface::n_vec_dim(mesh, fe_type);
139+
if (vector_dim > vec_dim)
140+
vec_dim = vector_dim;
141+
}
142+
else
143+
n_scalar_vars++;
144+
145+
}
146+
147+
// ready for use
148+
this->_initialized = true;
123149
}
124150

125151

0 commit comments

Comments
 (0)