180 if (
auto fe_method_ptr =
fePtr.lock()) {
186 const auto problem_name = fe_method_ptr->problemPtr->getName();
188 SmartPetscObj<IS> is_sum;
190 for (
auto bc : bc_mng->getBcMapByBlockName()) {
191 if (
auto disp_bc = bc.second->dispBcPtr) {
193 auto &bc_id = bc.first;
195 auto regex_str = (boost::format(
"%s_(.*)") % problem_name).str();
196 if (std::regex_match(bc_id, std::regex(regex_str))) {
202 <<
"Apply EssentialPreProc<DisplacementCubitBcData>: "
203 << problem_name <<
"_" <<
field_name <<
"_" << block_name;
205 const bool is_rotation =
206 disp_bc->data.flag4 || disp_bc->data.flag5 || disp_bc->data.flag6;
208 auto ents = bc.second->bcEnts;
210 std::array<SmartPetscObj<IS>, 3> is_xyz;
211 auto prb_name = fe_method_ptr->problemPtr->getName();
213 if (disp_bc->data.flag1 || is_rotation) {
214 CHKERR is_mng->isCreateProblemFieldAndRankLocal(
217 if (disp_bc->data.flag2 || is_rotation) {
218 CHKERR is_mng->isCreateProblemFieldAndRankLocal(
221 if (disp_bc->data.flag3 || is_rotation) {
222 CHKERR is_mng->isCreateProblemFieldAndRankLocal(
226 auto get_is_sum = [](
auto is1,
auto is2) {
229 return SmartPetscObj<IS>(is);
232 for (
auto &is : is_xyz) {
237 is_sum = get_is_sum(is_sum, is);
246 if (
auto fe_ptr =
fePtr.lock()) {
248 auto snes_ctx = fe_ptr->snes_ctx;
249 auto ts_ctx = fe_ptr->ts_ctx;
251 SmartPetscObj<Vec>
f =
252 vRhs ?
vRhs : SmartPetscObj<Vec>(fe_ptr->f,
true);
254 if (fe_ptr->vecAssembleSwitch) {
255 if ((*fe_ptr->vecAssembleSwitch) && !
vRhs) {
256 CHKERR VecGhostUpdateBegin(
f, ADD_VALUES, SCATTER_REVERSE);
257 CHKERR VecGhostUpdateEnd(
f, ADD_VALUES, SCATTER_REVERSE);
260 *fe_ptr->vecAssembleSwitch =
false;
264 const int *index_ptr;
265 CHKERR ISGetIndices(is_sum, &index_ptr);
267 CHKERR ISGetLocalSize(is_sum, &size);
272 CHKERR vec_mng->setLocalGhostVector(problem_name,
ROW, tmp_x,
273 INSERT_VALUES, SCATTER_FORWARD);
275 CHKERR VecGetArrayRead(tmp_x, &u);
281 CHKERR VecGhostUpdateBegin(x, INSERT_VALUES, SCATTER_FORWARD);
282 CHKERR VecGhostUpdateEnd(x, INSERT_VALUES, SCATTER_FORWARD);
287 for (
auto i = 0;
i != size; ++
i) {
288 a[index_ptr[
i]] =
vDiag * (
v[index_ptr[
i]] - u[index_ptr[
i]]);
291 CHKERR VecRestoreArrayRead(x, &
v);
294 for (
auto i = 0;
i != size; ++
i) {
295 a[index_ptr[
i]] =
vDiag * u[index_ptr[
i]];
299 CHKERR VecRestoreArrayRead(tmp_x, &u);
301 CHKERR ISRestoreIndices(is_sum, &index_ptr);
307 "Can not lock shared pointer");