28 _sync_to_var_name(getParam<VariableName>(
"sync_variable")),
31 _ts(_external_petsc_app.getPetscTS()),
33 _petsc_sol(declareRestartableData<Vec>(
"petsc_sol")),
34 _petsc_sol_old(declareRestartableData<Vec>(
"petsc_sol_old")),
35 _petsc_udot(declareRestartableData<Vec>(
"petsc_udot"))
38 LibmeshPetscCall(TSGetDM(
_ts, &da));
40 LibmeshPetscCall(DMCreateGlobalVector(da, &
_petsc_sol));
43 LibmeshPetscCall(VecMPISetGhost(
_petsc_sol, 0,
nullptr));
109 if (direction == Direction::FROM_EXTERNAL_APP)
111 _console <<
"syncSolutions from external petsc App" << std::endl;
118 PetscInt i, j, xs, ys, xm, ym, Mx;
119 PetscScalar ** _petsc_sol_array;
120 LibmeshPetscCall(TSGetDM(
_ts, &da));
121 LibmeshPetscCall(DMDAGetInfo(da,
135 LibmeshPetscCall(DMDAGetCorners(da, &xs, &ys, NULL, &xm, &ym, NULL));
136 LibmeshPetscCall(DMDAVecGetArray(da,
_petsc_sol, &_petsc_sol_array));
143 0,
_sync_to_var_name, Moose::VarKindType::VAR_ANY, Moose::VarFieldType::VAR_FIELD_STANDARD);
145 for (j = ys; j < ys + ym; j++)
146 for (i = xs; i < xs + xm; i++)
148 Node * to_node = to_mesh.node_ptr(i + j * Mx);
153 if (to_node->n_comp(sync_to_var.sys().number(), sync_to_var.number()) > 1)
154 mooseError(
"Does not support multiple components");
156 dof_id_type dof = to_node->dof_number(sync_to_var.sys().number(), sync_to_var.number(), 0);
158 sync_to_var.sys().solution().set(dof, _petsc_sol_array[j][i]);
161 sync_to_var.sys().solution().close();
163 LibmeshPetscCall(DMDAVecRestoreArray(da,
_petsc_sol, &_petsc_sol_array));
166 sync_to_var.sys().update();
168 else if (direction == Direction::TO_EXTERNAL_APP)
170 _console <<
"syncSolutions to external petsc App " << std::endl;
virtual const MooseVariableFieldBase & getVariable(const THREAD_ID tid, const std::string &var_name, Moose::VarKindType expected_var_type=Moose::VarKindType::VAR_ANY, Moose::VarFieldType expected_var_field_type=Moose::VarFieldType::VAR_FIELD_ANY) const override