@@ -430,6 +430,31 @@ namespace BoundaryConditionsHelpers
430430 /* ---------------------------------------------------------------------------*/
431431 /* ---------------------------------------------------------------------------*/
432432
433+ inline void applyDirichletToNodeGroupRhsOnly (const Int32 dof_index, Real value, Accelerator::RunQueue* queue, IMesh* mesh, DoFLinearSystem& linear_system, const FemDoFsOnNodes& dofs_on_nodes, NodeGroup& node_group)
434+ {
435+ ARCANE_CHECK_PTR (queue);
436+ ARCANE_CHECK_PTR (mesh);
437+
438+ NodeInfoListView nodes_infos (mesh->nodeFamily ());
439+ auto node_dof (dofs_on_nodes.nodeDoFConnectivityView ());
440+
441+ auto command = Accelerator::makeCommand (queue);
442+ auto in_out_forced_info = Accelerator::viewInOut (command, linear_system.getForcedInfo ());
443+ auto in_out_rhs_variable = Accelerator::viewInOut (command, linear_system.rhsVariable ());
444+
445+ command << RUNCOMMAND_ENUMERATE (NodeLocalId, node_lid, node_group)
446+ {
447+ if (nodes_infos.isOwn (node_lid)) {
448+ DoFLocalId dof_id = node_dof.dofId (node_lid, dof_index);
449+ in_out_forced_info[dof_id] = true ;
450+ in_out_rhs_variable[dof_id] = value;
451+ }
452+ };
453+ }
454+
455+ /* ---------------------------------------------------------------------------*/
456+ /* ---------------------------------------------------------------------------*/
457+
433458 inline void applyDirichletToNodeGroupViaPenalty (const Int32 dof_index, Real value, Real penalty, Accelerator::RunQueue* queue, IMesh* mesh, DoFLinearSystem& linear_system, const FemDoFsOnNodes& dofs_on_nodes, NodeGroup& node_group)
434459 {
435460 ARCANE_CHECK_PTR (queue);
@@ -564,6 +589,83 @@ namespace BoundaryConditions
564589 }
565590 }
566591
592+ /* ---------------------------------------------------------------------------*/
593+ /* *
594+ * @brief Applies Dirichlet boundary conditions to RHS.
595+ *
596+ * - For RHS vector `𝐛`, the Dirichlet DOF term is scaled by `𝑃`.
597+ */
598+ /* ---------------------------------------------------------------------------*/
599+
600+ inline void applyDirichletToRhs (BC::IDirichletBoundaryCondition* bs, const FemDoFsOnNodes& dofs_on_nodes, DoFLinearSystem& linear_system, IMesh* mesh, Accelerator::RunQueue* queue)
601+ {
602+ ARCANE_CHECK_PTR (bs);
603+
604+ FaceGroup face_group = bs->getSurface ();
605+ NodeGroup node_group = face_group.nodeGroup ();
606+
607+ const StringConstArrayView u_dirichlet_string = bs->getValue ();
608+
609+ for (Int32 dof_index = 0 ; dof_index < u_dirichlet_string.size (); ++dof_index) {
610+ if (u_dirichlet_string[dof_index] != " NULL" ) {
611+
612+ Real value = std::stod (u_dirichlet_string[dof_index].localstr ());
613+
614+ if (bs->getEnforceDirichletMethod () == " Penalty" ) {
615+ Real penalty = bs->getPenalty ();
616+ value = value * penalty;
617+ BoundaryConditionsHelpers::applyDirichletToNodeGroupRhsOnly (dof_index, value, queue, mesh, linear_system, dofs_on_nodes, node_group);
618+ }
619+ else if (bs->getEnforceDirichletMethod () == " RowElimination" ) {
620+ BoundaryConditionsHelpers::applyDirichletToNodeGroupRhsOnly (dof_index, value, queue, mesh, linear_system, dofs_on_nodes, node_group);
621+ }
622+ else if (bs->getEnforceDirichletMethod () == " RowColumnElimination" ) {
623+ ARCANE_THROW (Arccore::NotImplementedException, " RowColumnElimination is not supported." );
624+ }
625+ else {
626+ ARCANE_FATAL (" Unknown method to enforce Dirichlet BC: '{0}'" , bs->getEnforceDirichletMethod ());
627+ }
628+ }
629+ }
630+ }
631+
632+ /* ---------------------------------------------------------------------------*/
633+ /* *
634+ * @brief Applies Point Dirichlet boundary conditions to RHS.
635+ *
636+ * - For RHS vector `𝐛`, the Dirichlet DOF term is scaled by `𝑃`.
637+ */
638+ /* ---------------------------------------------------------------------------*/
639+
640+ inline void applyPointDirichletToRhs (BC::IDirichletPointCondition* bs, const FemDoFsOnNodes& dofs_on_nodes, DoFLinearSystem& linear_system, IMesh* mesh, Accelerator::RunQueue* queue)
641+ {
642+ ARCANE_CHECK_PTR (bs);
643+ NodeGroup node_group = bs->getNode ();
644+
645+ const StringConstArrayView u_dirichlet_str = bs->getValue ();
646+
647+ for (Int32 dof_index = 0 ; dof_index < u_dirichlet_str.size (); ++dof_index) {
648+ if (u_dirichlet_str[dof_index] != " NULL" ) {
649+ Real value = std::stod (u_dirichlet_str[dof_index].localstr ());
650+
651+ if (bs->getEnforceDirichletMethod () == " Penalty" ){
652+ Real penalty = bs->getPenalty ();
653+ value = value * penalty;
654+ BoundaryConditionsHelpers::applyDirichletToNodeGroupRhsOnly (dof_index, value, queue, mesh, linear_system, dofs_on_nodes, node_group);
655+ }
656+ else if (bs->getEnforceDirichletMethod () == " RowElimination" ) {
657+ BoundaryConditionsHelpers::applyDirichletToNodeGroupRhsOnly (dof_index, value, queue, mesh, linear_system, dofs_on_nodes, node_group);
658+ }
659+ else if (bs->getEnforceDirichletMethod () == " RowColumnElimination" ) {
660+ ARCANE_THROW (Arccore::NotImplementedException, " RowColumnElimination is not supported." );
661+ }
662+ else {
663+ ARCANE_FATAL (" Unknown method to enforce Dirichlet BC: '{0}'" , bs->getEnforceDirichletMethod ());
664+ }
665+ }
666+ }
667+ }
668+
567669}; // namespace BoundaryConditions
568670
569671class BoundaryConditions2D
0 commit comments