|
[Sponsors] |
How to add an algebric expression for vector field. |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
September 8, 2022, 07:04 |
How to add an algebric expression for vector field.
|
#1 |
New Member
prakash verma
Join Date: Mar 2021
Posts: 2
Rep Power: 0 |
Hi everyone,
I'm developing a solver for ferrofluid flow, where I have to define the Magnetic field in X and Y directions in terms of x and y variables (in form of algebraic expressions). I have already defined the H vector field, but I'm getting problems defining the H field in terms of x and y variables. Can someone please tell me how to define a volume vector field in OpenFOAM when u know the algebraic expression for the x and y component of the vector field? I'm modifying mhdFoam solver by adding a new momentum source term in UEqn and my solver looks like this. /*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. Application mhdFoam Description Solver for magnetohydrodynamics (MHD): incompressible, laminar flow of a conducting fluid under the influence of a magnetic field. An applied magnetic field H acts as a driving force, at present boundary conditions cannot be set via the electric field E or current density J. The fluid viscosity nu, conductivity sigma and permeability mu are read in as uniform constants. A fictitious magnetic flux pressure pB is introduced in order to compensate for discretization errors and create a magnetic face flux field which is divergence-free as required by Maxwell's equations. However, in this formulation discretization error prevents the normal stresses in UB from canceling with those from BU, but it is unknown whether this is a serious error. A correction could be introduced whereby the normal stresses in the discretized BU term are replaced by those from the UB term, but this would violate the boundedness constraint presently observed in the present numerics which guarantees div(U) and div(H) are zero. \*---------------------------------------------------------------------------*/ #include "fvCFD.H" #include "pisoControl.H" #include "pressureReference.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // int main(int argc, char *argv[]) { #include "postProcess.H" #include "setRootCaseLists.H" #include "createTime.H" #include "createMesh.H" #include "createControl.H" #include "createFields.H" #include "initContinuityErrs.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< nl << "Starting time loop" << endl; while (runTime.loop()) { Info<< "Time = " << runTime.userTimeName() << nl << endl; #include "CourantNo.H" // #include "HEqn.H" H == B/(mu*(1+Chi)); { fvVectorMatrix UEqn ( fvm::ddt(U) + fvm::div(phi, U) - fvm::laplacian(nu, U) -(mu/rho)*Chi*(H&fvc::grad(Chi))*H ); if (piso.momentumPredictor()) { solve(UEqn == -fvc::grad(p)); } // --- PISO loop while (piso.correct()) { volScalarField rAU(1.0/UEqn.A()); surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU)); volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p)); surfaceScalarField phiHbyA ( "phiHbyA", fvc::flux(HbyA) + rAUf*fvc::ddtCorr(U, phi) ); // Update the pressure BCs to ensure flux consistency constrainPressure(p, U, phiHbyA, rAUf); while (piso.correctNonOrthogonal()) { fvScalarMatrix pEqn ( fvm::laplacian(rAUf, p) == fvc::div(phiHbyA) ); pEqn.setReference ( pressureReference.refCell(), pressureReference.refValue() ); pEqn.solve(); if (piso.finalNonOrthogonalIter()) { phi = phiHbyA - pEqn.flux(); } } #include "continuityErrs.H" U = HbyA - rAU*fvc::grad(p); U.correctBoundaryConditions(); } #include "TEqn.H" Chi == Chi0/(1+betaT*(T-Tr)); } // --- B-PISO loop while (bpiso.correct()) { fvVectorMatrix BEqn ( fvm::ddt(B) + fvm::div(phi, B) - fvc::div(phiB, U) - fvm::laplacian(DB, B) ); BEqn.solve(); volScalarField rAB(1.0/BEqn.A()); surfaceScalarField rABf("rABf", fvc::interpolate(rAB)); phiB = fvc::flux(B); while (bpiso.correctNonOrthogonal()) { fvScalarMatrix pBEqn ( fvm::laplacian(rABf, pB) == fvc::div(phiB) ); pBEqn.solve(); if (bpiso.finalNonOrthogonalIter()) { phiB -= pBEqn.flux(); } } #include "magneticFieldErr.H" } runTime.write(); } Info<< "End\n" << endl; return 0; } // ************************************************** *********************** // |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Add units to expression using TUI | RobR_CFD | FLUENT | 2 | September 15, 2022 19:48 |
How to add this Expression | Rajkool | Fluent Multiphase | 0 | July 26, 2020 14:40 |
[PyFoam] and paraview | eelcovv | OpenFOAM Community Contributions | 28 | May 30, 2016 10:23 |
Something doens't work with wallHeatFlux utility or externalWallHeatFluxTemperat BC!! | zfaraday | OpenFOAM Post-Processing | 0 | February 5, 2015 17:47 |
writing execFlowFunctionObjects | immortality | OpenFOAM Post-Processing | 30 | September 15, 2013 07:16 |