Line data Source code
1 : /********************************************************************/ 2 : /* SOFTWARE COPYRIGHT NOTIFICATION */ 3 : /* Cardinal */ 4 : /* */ 5 : /* (c) 2021 UChicago Argonne, LLC */ 6 : /* ALL RIGHTS RESERVED */ 7 : /* */ 8 : /* Prepared by UChicago Argonne, LLC */ 9 : /* Under Contract No. DE-AC02-06CH11357 */ 10 : /* With the U. S. Department of Energy */ 11 : /* */ 12 : /* Prepared by Battelle Energy Alliance, LLC */ 13 : /* Under Contract No. DE-AC07-05ID14517 */ 14 : /* With the U. S. Department of Energy */ 15 : /* */ 16 : /* See LICENSE for full restrictions */ 17 : /********************************************************************/ 18 : 19 : #ifdef ENABLE_NEK_COUPLING 20 : 21 : #include "NekViscousSurfaceForce.h" 22 : 23 : registerMooseObject("CardinalApp", NekViscousSurfaceForce); 24 : 25 : InputParameters 26 181 : NekViscousSurfaceForce::validParams() 27 : { 28 181 : InputParameters params = NekSidePostprocessor::validParams(); 29 362 : MooseEnum comp("x y z total", "total"); 30 362 : params.addParam<MooseEnum>( 31 : "component", 32 : comp, 33 : "Component of viscous force to compute. 'total' takes the magnitude of the viscous force, " 34 : "while 'x', 'y', or 'z' return individual components."); 35 181 : params.addClassDescription("Viscous force that the fluid exerts on a surface"); 36 181 : return params; 37 181 : } 38 : 39 54 : NekViscousSurfaceForce::NekViscousSurfaceForce(const InputParameters & parameters) 40 108 : : NekSidePostprocessor(parameters), _component(getParam<MooseEnum>("component")) 41 : { 42 54 : if (_pp_mesh != nek_mesh::fluid) 43 1 : mooseError("The 'NekViscousSurfaceForce' postprocessor can only be applied to the fluid mesh " 44 : "boundaries!\n" 45 : "Please change 'mesh' to 'fluid'."); 46 : 47 53 : if (_nek_problem->nondimensional()) 48 0 : mooseError("The NekViscousSurfaceForce object is missing the implementation to convert the " 49 : "non-dimensional viscous drag to dimensional form. Please contact the developers if " 50 : "this is impacting your analysis."); 51 53 : } 52 : 53 : Real 54 1048 : NekViscousSurfaceForce::getValue() const 55 : { 56 1048 : auto nrs = nekrs::nrsPtr(); 57 1048 : auto mesh = nekrs::flowMesh(); 58 : 59 1048 : auto o_Sij = nrs->strainRate(); 60 1048 : auto o_bID = platform->device.malloc<int>(_boundary.size(), _boundary.data()); 61 : 62 : auto o_tangentialViscousTraction = 63 1048 : nrs->viscousShearStress(o_bID, o_Sij); // tau dot n - ((tau dot n) dot n) * n 64 1048 : auto o_normalViscousTraction = nrs->viscousNormalStress(o_bID, o_Sij); // ((tau dot n) dot n) * n 65 : 66 1048 : const dlong Ntotal = o_tangentialViscousTraction.size() / mesh->dim; 67 : auto fvT = 68 1048 : mesh->surfaceAreaMultiplyIntegrate(mesh->dim, Ntotal, o_bID, o_tangentialViscousTraction); 69 1048 : auto fvN = mesh->surfaceAreaMultiplyIntegrate(mesh->dim, Ntotal, o_bID, o_normalViscousTraction); 70 : 71 1048 : auto fx = fvT[0] + fvN[0]; 72 1048 : auto fy = fvT[1] + fvN[1]; 73 1048 : auto fz = fvT[2] + fvN[2]; 74 : 75 1048 : o_Sij.free(); 76 1048 : o_bID.free(); 77 : 78 1048 : if (_component == "total") 79 1012 : return std::sqrt(fx * fx + fy * fy + fz * fz); 80 36 : else if (_component == "x") 81 : return fx; 82 24 : else if (_component == "y") 83 : return fy; 84 12 : else if (_component == "z") 85 : return fz; 86 : else 87 0 : mooseError("Unknown 'component' in NekViscousSurfaceForce!"); 88 1048 : } 89 : 90 : #endif