Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Enh/add non zero bc #31

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

WIP Enh/add non zero bc #31

wants to merge 2 commits into from

Conversation

greole
Copy link
Contributor

@greole greole commented Nov 26, 2024

This PR adds some non-zero initial fields for T and U for the scalarAdvection case. Below are some screenshots of the initial fields of T and U. I'm open to use a different method to generate the fields in order to decrease the file size and make it easier to scale the mesh.

Screenshot 2024-11-26 at 14 05 29
Screenshot 2024-11-26 at 14 05 18

@happyKitesurfer
Copy link

happyKitesurfer commented Nov 26, 2024

I set the T field by the setFields utility: The dictionary looks like this:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v2406                                 |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      setFieldsDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

defaultFieldValues
(
    volScalarFieldValue T 300
);

regions
(
    boxToCell
    {
        box (0.25 0.75 -1) (0.75 1. 1);
        fieldValues
        (
            volScalarFieldValue T 273
        );
    }
);


// ************************************************************************* //

@greole
Copy link
Contributor Author

greole commented Nov 26, 2024

Is there something similar for U though?

@happyKitesurfer
Copy link

happyKitesurfer commented Nov 26, 2024

you can specify a custom inlet profile like this:

boundaryField
{
    #includeEtc "caseDicts/setConstraintTypes"
    
    inlet
    {
        
        name    parabolicInlet;
        type    codedFixedValue;

        code
        #{
            // Uncomment for testing on non-windows systems [fragile]
            // IOobject::scopeSeparator = '_';

            const scalar Q(4.17e-08);
            const scalar maxR(gMax(this->patch().Cf().component(0)));
            scalar vMax;
            vMax = 2.*Q/(M_PI*pow(maxR,2));
            scalarField vz(vMax*(1. -  pow(this->patch().Cf().component(0),2)/pow(maxR,2)));
            

            vectorField v(this->patch().size(), vector(0, 0, 0));
            v.replace(vector::Z, vz);
            operator==(v);
        #};

        value           $internalField;
        
        
    }

Is this what you are looking for? Or do you want to specify the velocity in the whole domain?

@greole
Copy link
Contributor Author

greole commented Nov 26, 2024

That looks good. I don't think we have specific needs for the velocity profile, just something that moves the temperature blob.

@happyKitesurfer
Copy link

I think then specifying an internal field which is not zero will do the job

@HenningScheufler
Copy link
Collaborator

@greole
Copy link
Contributor Author

greole commented Nov 28, 2024

So here are the expressions used inititially:
for U

Foam::scalarField X(mesh.C().component(0));
Foam::scalarField Y(mesh.C().component(1));
Foam::scalarField u(-Foam::sin(2.0 * pi * Y) * Foam::pow(Foam::sin(pi * X), 2.0));
Foam::scalarField w(Foam::sin(2.0 * pi * X) * Foam::pow(Foam::sin(pi * Y), 2.0));
forAll(U0, celli)
{
       U0[celli].x() = u[celli];
       U0[celli].y() = w[celli];
       U0[celli].z() = 0.0;
}

for T

Foam::scalar spread = 0.05;
forAll(T, celli)
       {
           T[celli] = std::exp(
               -0.5
               * (std::pow((mesh.C()[celli].x() - 0.5) / spread, 2.0)
                  + std::pow((mesh.C()[celli].y() - 0.75) / spread, 2.0))
           );
       }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ScalarAdvection example case has uniform initial conditions of zero everywhere
3 participants