Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://mooseframework.inl.gov 3 : //* 4 : //* All rights reserved, see COPYRIGHT for full restrictions 5 : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT 6 : //* 7 : //* Licensed under LGPL 2.1, please see LICENSE for details 8 : //* https://www.gnu.org/licenses/lgpl-2.1.html 9 : 10 : #ifdef MOOSE_MFEM_ENABLED 11 : 12 : #include "MFEMVectorFESpace.h" 13 : 14 : registerMooseObject("MooseApp", MFEMVectorFESpace); 15 : 16 : InputParameters 17 9436 : MFEMVectorFESpace::validParams() 18 : { 19 9436 : InputParameters params = MFEMSimplifiedFESpace::validParams(); 20 18872 : params.addClassDescription( 21 : "Convenience class to construct vector finite element spaces, abstracting away some of the " 22 : "mathematical complexity of specifying the dimensions."); 23 37744 : MooseEnum fec_types("H1 ND RT L2", "H1"); 24 37744 : params.addParam<MooseEnum>("fec_type", fec_types, "Specifies the family of FE shape functions."); 25 : MooseEnum closed_basis_types("GaussLobatto=1 ClosedUniform=4 Serendipity=6 ClosedGL=7", 26 37744 : "GaussLobatto"); 27 37744 : params.addParam<MooseEnum>("closed_basis", 28 : closed_basis_types, 29 : "Specifies the closed basis used for ND and RT elements."); 30 : MooseEnum basis_types("GaussLegendre GaussLobatto Positive OpenUniform ClosedUniform " 31 : "OpenHalfUniform Serendipity ClosedGL IntegratedGLL", 32 37744 : "GaussLegendre"); 33 37744 : params.addParam<MooseEnum>( 34 : "open_basis", basis_types, "Specifies the open basis used for ND and RT elements."); 35 18872 : basis_types = "GaussLobatto"; 36 37744 : params.addParam<MooseEnum>( 37 : "basis", 38 : basis_types, 39 : "Specifies the basis used for H1 and L2 vector elements. H1 spaces require a closed basis " 40 : "(GaussLobatto Positive ClosedUniform Serendipity ClosedGL)"); 41 28308 : params.addParam<int>("range_dim", 42 18872 : 0, 43 : "The number of components of the vectors in reference space. Zero " 44 : "(the default) means it will be the same as the problem dimension. " 45 : "Note that MFEM does not currently support 2D vectors in 1D space " 46 : "for ND and RT elements."); 47 37744 : MooseEnum fec_maps("VALUE INTEGRAL", "VALUE", true); 48 28308 : params.addParam<MooseEnum>( 49 : "fec_map", 50 : fec_maps, 51 : "Specify the FE map type used VALUE or INTEGRAL (meaningful for L2 only)"); 52 : 53 18872 : return params; 54 9436 : } 55 : 56 402 : MFEMVectorFESpace::MFEMVectorFESpace(const InputParameters & parameters) 57 : : MFEMSimplifiedFESpace(parameters), 58 402 : _fec_type(getParam<MooseEnum>("fec_type")), 59 1608 : _range_dim(getParam<int>("range_dim")) 60 : { 61 402 : } 62 : 63 : std::string 64 402 : MFEMVectorFESpace::getFECName() const 65 : { 66 402 : const int pdim = getProblemDim(); 67 402 : std::string actual_type = _fec_type; 68 402 : if ((_fec_type == "ND" || _fec_type == "RT") && _range_dim != 0 && _range_dim != pdim) 69 : { 70 24 : if (_range_dim != 3) 71 112 : mooseError("No " + _fec_type + " finite element collection available for " + 72 144 : std::to_string(_range_dim) + "D vectors in " + std::to_string(pdim) + "D space."); 73 8 : actual_type += "_R" + std::to_string(pdim) + "D"; 74 : } 75 : 76 386 : std::string basis = _fec_type == "L2" ? "_T" : "@"; 77 : 78 386 : if (_fec_type == "ND" || _fec_type == "RT") 79 : { 80 906 : if (isParamSetByUser("basis")) 81 0 : mooseWarning("basis parameter ignored, using closed_basis/open_basis parameters instead"); 82 604 : basis += mfem::BasisType::GetChar(getParam<MooseEnum>("closed_basis")); 83 906 : basis += mfem::BasisType::GetChar(getParam<MooseEnum>("open_basis")); 84 : } 85 84 : else if (_fec_type == "H1" || _fec_type == "L2") 86 : { 87 420 : if (isParamSetByUser("closed_basis") || isParamSetByUser("open_basis")) 88 0 : mooseWarning("closed_basis/open_basis parameter ignored, using basis parameter instead"); 89 84 : basis += _fec_type == "L2" 90 330 : ? std::to_string(getParam<MooseEnum>("basis")) 91 258 : : std::string({mfem::BasisType::GetChar(getParam<MooseEnum>("basis"))}); 92 : } 93 : 94 : // This is to get around an MFEM bug (to be removed in #31525) 95 1110 : basis = (basis == "@Gg" || basis == "@G" || basis == "_T0") ? "" : basis; 96 : 97 386 : if (_fec_map == "INTEGRAL" && _fec_type == "L2") 98 : { 99 0 : return "L2Int" + basis + "_" + std::to_string(pdim) + "D_P" + std::to_string(_fec_order); 100 : } 101 : 102 386 : return actual_type + basis + "_" + std::to_string(pdim) + "D_P" + std::to_string(_fec_order); 103 402 : } 104 : 105 : int 106 402 : MFEMVectorFESpace::getVDim() const 107 : { 108 402 : if (_fec_type == "H1" || _fec_type == "L2") 109 : { 110 84 : return _range_dim == 0 ? getProblemDim() : _range_dim; 111 : } 112 : else 113 : { 114 318 : return 1; 115 : } 116 : } 117 : 118 : #endif