CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Updating a custom field using values from fvModels

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 3, 2024, 10:50
Question Updating a custom field using values from fvModels
  #1
New Member
 
Marius
Join Date: Aug 2020
Location: Germany
Posts: 11
Rep Power: 6
Muerio is on a distinguished road
Hello everyone,

I'm trying to update the values of a custom field I added to the multicomponentFluid solver in OpenFOAM 11.
The field should only depend on the values from a fvModel and shouldn't be affected by the flow itself.

Therefore I tried to extend the thermophysicalPredictor like this (copied from component fields Y_ and removed terms for transport):
Code:
void Foam::solvers::electrochemFluid::thermophysicalPredictor()
{
    tmp<fv::convectionScheme<scalar>> mvConvection(
        fv::convectionScheme<scalar>::New(mesh, fields, phi,
                                          mesh.schemes().div("div(phi,Yi_h)")));

    reaction->correct();

    volScalarField &myField = myField_;
    fvScalarMatrix myFieldEqn(fvm::ddt(myField) == fvModels().source(myField));


    myFieldEqn.relax();

    fvConstraints().constrain(myFieldEqn);

    myFieldEqn.solve("myField");

    fvConstraints().constrain(myField);

    forAll(Y, i)
    {
        ...
For testing purposes I use a simple fvModel that assigns the value of 1.0 to all cells:
Code:
forAll(cells, i){eqn.source()[cells[i]] = 1.0;}
All boundaries are defined as zeroGradient:
Code:
internalField   uniform 0;

boundaryField
{
    ".*"
    {
        type            zeroGradient;
    }
}
It compiles and starts without issue, but once it reaches the "myFieldEqn.solve" line, the solver crashes with an Arithmetic exception in Foam::divide. I guess it divides by 0 while trying to solve?!

Is there something obvious I missed?
What could I try to resolve this issue?

Thank you in advance for any help!
Muerio is offline   Reply With Quote

Reply

Tags
arithmetic exception, custom field, fvmodel, fvmodels


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create non-uniform internal field values based on a graph or table finn_amann OpenFOAM Pre-Processing 0 June 28, 2023 09:20
getting cutplanes of a custom vector field (vorticity in my case) zog OpenFOAM Post-Processing 0 February 2, 2023 19:26
Can i take contours from Custom field function i defined ? rahulohlan FLUENT 3 April 18, 2017 14:39
Store data in a different field from a custom BC cstuart OpenFOAM Programming & Development 0 March 21, 2017 11:14
Setting patch field values equal to internal field values leroyv OpenFOAM Programming & Development 1 October 21, 2014 16:49


All times are GMT -4. The time now is 16:25.