1111
1212#include "EquationSystem.h"
1313#include "libmesh/int_range.h"
14- #include "../../../contrib/mfem/general/forall.hpp"
1514
1615namespace Moose ::MFEM
1716{
@@ -130,7 +129,7 @@ EquationSystem::Init(Moose::MFEM::GridFunctions & gridfunctions,
130129 mfem ::AssemblyLevel assembly_level )
131130{
132131 _assembly_level = assembly_level ;
133-
132+
134133 // Extract which coupled variables are to be trivially eliminated and which are trial variables
135134 SetTrialVariableNames ();
136135
@@ -328,19 +327,19 @@ EquationSystem::BuildJacobian(mfem::BlockVector & trueX, mfem::BlockVector & tru
328327void
329328EquationSystem ::Mult (const mfem ::Vector & sol , mfem ::Vector & residual ) const
330329{
331- const_cast < EquationSystem * > (this )-> CopyVec (sol ,_trueBlockSol );
330+ const_cast < EquationSystem * > (this )-> CopyVec (sol , _trueBlockSol );
332331
333- for (int i = 0 ; i < _trial_var_names .size (); i ++ )
332+ for (unsigned int i = 0 ; i < _trial_var_names .size (); i ++ )
334333 {
335334 auto & trial_var_name = _trial_var_names .at (i );
336335 _gfuncs -> Get (trial_var_name )-> Distribute (& (_trueBlockSol .GetBlock (i )));
337336 }
338337
339338 UpdateJacobian ();
340339
341- _BlockResidual = 0.0 ;
340+ _BlockResidual = 0.0 ;
342341
343- for (int i = 0 ; i < _test_var_names .size (); i ++ )
342+ for (unsigned int i = 0 ; i < _test_var_names .size (); i ++ )
344343 {
345344 auto & test_var_name = _test_var_names .at (i );
346345
@@ -358,77 +357,81 @@ EquationSystem::Mult(const mfem::Vector & sol, mfem::Vector & residual) const
358357 _BlockResidual .GetBlock (i ) -= b ;
359358 _BlockResidual .GetBlock (i ) *= -1 ;
360359
361- if (_non_linear )
362- _BlockResidual .GetBlock (i ).SetSubVector (_ess_tdof_lists .at (i ),0.0 );
360+ if (_non_linear )
361+ _BlockResidual .GetBlock (i ).SetSubVector (_ess_tdof_lists .at (i ), 0.0 );
363362 }
364363
365- if (!_non_linear ){
366- const_cast < EquationSystem * > (this )-> FormLinearSystem (_jacobian , _trueBlockSol , _BlockResidual );
367- const_cast < EquationSystem * > (this )-> CopyVec (_BlockResidual , residual );
368- }else {
369- const_cast < EquationSystem * > (this )-> CopyVec (_BlockResidual , residual );
370- const_cast < EquationSystem * > (this )-> FormLinearSystem (_jacobian , _trueBlockSol , _BlockResidual );
364+ if (!_non_linear )
365+ {
366+ const_cast < EquationSystem * > (this )-> FormLinearSystem (_jacobian , _trueBlockSol , _BlockResidual );
367+ const_cast < EquationSystem * > (this )-> CopyVec (_BlockResidual , residual );
368+ }
369+ else
370+ {
371+ const_cast < EquationSystem * > (this )-> CopyVec (_BlockResidual , residual );
372+ const_cast < EquationSystem * > (this )-> FormLinearSystem (_jacobian , _trueBlockSol , _BlockResidual );
371373 }
372374
373375 residual *= -1.0 ;
374376
375- if (!_non_linear )
376- {
377- _jacobian -> AddMult (sol , residual );
378- }
377+ if (!_non_linear )
378+ {
379+ _jacobian -> AddMult (sol , residual );
380+ }
379381
380382 sol .HostRead ();
381383 residual .HostRead ();
382384}
383385
384386void
385- TimeDependentEquationSystem ::UpdateEssDerivativeVals (const mfem ::real_t & dt , const mfem ::Vector & x_old )
387+ TimeDependentEquationSystem ::UpdateEssDerivativeVals (const mfem ::real_t & dt ,
388+ const mfem ::Vector & x_old )
386389{
387- //Update the old vector
390+ // Update the old vector
388391 mfem ::BlockVector block_x_old ;
389392 block_x_old .Update (* _block_true_offsets );
390393
391- //Update the old vector
394+ // Update the old vector
392395 CopyVec (x_old , block_x_old );
393396
394- //Update the xs boundary conditions
397+ // Update the xs boundary conditions
395398 ApplyEssentialBCs ();
396399
397400 // Update the dxdts boundary conditions
398- for (int i = 0 ; i < _test_var_names .size (); i ++ )
401+ for (unsigned int i = 0 ; i < _test_var_names .size (); i ++ )
399402 {
400403 * (_var_ess_constraints .at (i )) -= block_x_old .GetBlock (i );
401404 * (_var_ess_constraints .at (i )) /= dt ;
402405 }
403- };
406+ }
404407
405408void
406409EquationSystem ::UpdateJacobian () const
407410{
408411
409- for (int i = 0 ; i < _test_var_names .size (); i ++ )
410- {
411- auto & test_var_name = _test_var_names .at (i );
412- auto blf = _blfs .Get (test_var_name );
413- blf -> Update ();
414- blf -> Assemble ();
415- }
412+ for (unsigned int i = 0 ; i < _test_var_names .size (); i ++ )
413+ {
414+ auto & test_var_name = _test_var_names .at (i );
415+ auto blf = _blfs .Get (test_var_name );
416+ blf -> Update ();
417+ blf -> Assemble ();
418+ }
416419
417- // Form off-diagonal blocks
418- for (int i = 0 ; i < _test_var_names .size (); i ++ )
420+ // Form off-diagonal blocks
421+ for (unsigned int i = 0 ; i < _test_var_names .size (); i ++ )
422+ {
423+ auto test_var_name = _test_var_names .at (i );
424+ for (unsigned int j = 0 ; j < _test_var_names .size (); j ++ )
419425 {
420- auto test_var_name = _test_var_names .at (i );
421- for ( int j = 0 ; j < _test_var_names . size (); j ++ )
426+ auto trial_var_name = _test_var_names .at (j );
427+ if ( _mblfs . Has ( test_var_name ) && _mblfs . Get ( test_var_name ) -> Has ( trial_var_name ) )
422428 {
423- auto trial_var_name = _test_var_names .at (j );
424- if (_mblfs .Has (test_var_name ) && _mblfs .Get (test_var_name )-> Has (trial_var_name ))
425- {
426- auto mblf = _mblfs .Get (test_var_name )-> Get (trial_var_name );
427- mblf -> Update ();
428- mblf -> Assemble ();
429- }
429+ auto mblf = _mblfs .Get (test_var_name )-> Get (trial_var_name );
430+ mblf -> Update ();
431+ mblf -> Assemble ();
430432 }
431433 }
434+ }
432435}
433436
434437mfem ::Operator &
@@ -554,7 +557,8 @@ EquationSystem::BuildMixedBilinearForms()
554557}
555558
556559void
557- EquationSystem ::BuildEquationSystem (Moose ::MFEM ::GridFunctions & gridfunctions , mfem ::Array < int > & btoffsets )
560+ EquationSystem ::BuildEquationSystem (Moose ::MFEM ::GridFunctions & gridfunctions ,
561+ mfem ::Array < int > & btoffsets )
558562{
559563 _gfuncs = & gridfunctions ;
560564 _block_true_offsets = & btoffsets ;
@@ -721,13 +725,14 @@ TimeDependentEquationSystem::FormLegacySystem(mfem::OperatorHandle & op,
721725 // }
722726 mfem ::Vector aux_x , aux_rhs ;
723727 // Update solution values on Dirichlet values to be in terms of du/dt instead of u
724- //mfem::Vector bc_x = *(_var_ess_constraints.at(i).get());
725- //bc_x -= *_eliminated_variables.Get(test_var_name);
726- //bc_x /= _dt_coef.constant;
728+ // mfem::Vector bc_x = *(_var_ess_constraints.at(i).get());
729+ // bc_x -= *_eliminated_variables.Get(test_var_name);
730+ // bc_x /= _dt_coef.constant;
727731
728732 // Form linear system for operator acting on vector of du/dt
729733 mfem ::HypreParMatrix * aux_a = new mfem ::HypreParMatrix ;
730- td_blf -> FormLinearSystem (_ess_tdof_lists .at (i ), * (_var_ess_constraints .at (i )), * lf , * aux_a , aux_x , aux_rhs );
734+ td_blf -> FormLinearSystem (
735+ _ess_tdof_lists .at (i ), * (_var_ess_constraints .at (i )), * lf , * aux_a , aux_x , aux_rhs );
731736 _h_blocks (i , i ) = aux_a ;
732737 truedXdt .GetBlock (i ) = aux_x ;
733738 trueRHS .GetBlock (i ) = aux_rhs ;
@@ -759,13 +764,14 @@ TimeDependentEquationSystem::FormSystem(mfem::OperatorHandle & op,
759764 // }
760765 mfem ::Vector aux_x , aux_rhs ;
761766 // Update solution values on Dirichlet values to be in terms of du/dt instead of u
762- //mfem::Vector bc_x = *(_var_ess_constraints.at(0).get());
763- //bc_x -= *_eliminated_variables.Get(test_var_name);
764- //bc_x /= _dt_coef.constant;
767+ // mfem::Vector bc_x = *(_var_ess_constraints.at(0).get());
768+ // bc_x -= *_eliminated_variables.Get(test_var_name);
769+ // bc_x /= _dt_coef.constant;
765770
766771 // Form linear system for operator acting on vector of du/dt
767772 mfem ::OperatorPtr aux_a ;
768- td_blf -> FormLinearSystem (_ess_tdof_lists .at (0 ), * (_var_ess_constraints .at (0 )), * lf , aux_a , aux_x , aux_rhs );
773+ td_blf -> FormLinearSystem (
774+ _ess_tdof_lists .at (0 ), * (_var_ess_constraints .at (0 )), * lf , aux_a , aux_x , aux_rhs );
769775
770776 truedXdt .GetBlock (0 ) = aux_x ;
771777 trueRHS .GetBlock (0 ) = aux_rhs ;
@@ -778,7 +784,8 @@ TimeDependentEquationSystem::FormSystem(mfem::OperatorHandle & op,
778784}
779785
780786void
781- TimeDependentEquationSystem ::UpdateEquationSystem (Moose ::MFEM ::GridFunctions & gridfunctions , mfem ::Array < int > & btoffsets )
787+ TimeDependentEquationSystem ::UpdateEquationSystem (Moose ::MFEM ::GridFunctions & gridfunctions ,
788+ mfem ::Array < int > & btoffsets )
782789{
783790 EquationSystem ::BuildEquationSystem (gridfunctions , btoffsets );
784791}
0 commit comments