CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   How to add AttachDetachFvMesh to layeredEngineMesh solver? (https://www.cfd-online.com/Forums/openfoam/119803-how-add-attachdetachfvmesh-layeredenginemesh-solver.html)

RJ87 June 25, 2013 08:12

How to add AttachDetachFvMesh to layeredEngineMesh solver?
 
Hi Foamers,

I'm looking to compile the engineMesh > layeredEngineMesh with dynamicMesh > attachDetach. I have tried to combine both files but I realize that layeredEngineMesh runs on move() while attachDetach runs on update().

How do I put them together?

Regards
RJ

mturcios777 June 25, 2013 12:46

If you can download a copy of OpenFOAM 1.6-ext, its engine library includes a class called layerAR that does what you want. I can confirm that this class works in 2.0.x through 2.2.x, with the caveat that you have to change some of the calls to polyTopoChanger. I did it a while ago and don't have access to the machine with the installation now, but its similar to the change I had to make to get attachDetach to work:

http://www.openfoam.org/mantisbt/view.php?id=786

Good luck!

RJ87 June 26, 2013 05:46

i take that as you are talking about mapPolyMesh function calling morphing.
And why is changeMesh() has to change to changeMesh(True) for it to work. Kinda lost there.

Can you point out which line do I need to change in my mapPoly.

mturcios777 June 26, 2013 12:19

I can't find the 1.6-ext file as the project isn't being actively hosted (at least that I can find). From what I remember, polyTopoChanger runs through all the topoChanges and executes them. The reason the new argument is used is that we are actually calling a different function that ends up calling the old changeMesh(). Search the online code database for changeMesh and you will see that there is one for polyTopoChanger and polyTopoChange. We want the first one (I think, again its been a while).

RJ87 June 28, 2013 02:00

Got it! changes to polyTopoChanger is not neccessary but instead layerAR.C only.
Adapted engineTopoChanger and layerAR to 2.2.x

The only files require changing is return true to return topoChange.valid(), changeMesh() to changeMesh(true), allpoints to points in layerAR.C.

That's all i think that the simulation seems to work fine from -180 to 180 with compiled with new moveEngineMesh with adapted engineTopoChanger. Gonna try including solvers next!

RJ87 June 29, 2013 08:59

Does anyone happen to know how to compile engineTopoChanger class in OpenFoam 2.2.x?

The adapted compilation worked in my laptop. I tried to do the same with my desktop and the case that's running in my laptop in transferred together. Apparently, inside my newEngineTopoChangerMesh.C says something like the below and my solver with the adapted engineTopoChanger selector refuse to start. Is there something I have to do to make my solver work?

// Enclose the creation of the engineGeometry to ensure it is
// deleted before the engineTopoChangerMesh is created otherwise the dictionary
// is entered in the database twice


Valid engineTopoChangerMesh types are :

2
(
myLayerAR
layerAR
)


From function engineTopoChangerMesh::New(const IOobject&)
in file engineTopoChangerMesh/engineTopoChangerMesh/newEngineTopoChangerMesh.C at line 67.

FOAM exiting

RJ87 July 4, 2013 08:01

Solver Crashed!
 
Simulation on diesel spray combustion on a hypothetical engine cylinder with customized sprayEngineFoam with adapted engineTopoChanger with layer addition and removal crashed. The dynamic mesh work fine I suppose as I tested with adapted moveDyMEngineMesh from -180 to 180 and ran checkMesh through it. Mesh seems to be O.K at each time interval. However, sprayEngineFoam crash at somewhere 58 CAD. I checked the mesh at that point over and over again. It looked the same like any other mesh motion before. Nothing different.

As for image; It's just a simple cylinder created with blockMesh by selecting the centre point twice. I'm pretty sure it works at I have test with sprayEngineFoam with engineMesh layered. But it crashed after having engineMesh replaced with adapted engineTopoChanger from 1.6-ext. Again, the engineTopoChanger performed as expected and tested with adapted moveDyMEngineMesh. It's just the solver seem to prefer engineMesh over engineTopoChangerMesh? Lol =D

P.S. I'm using OpenFOAM 2.2.X because of its sprayFoam Class and had to adapt 1.6-ext for it's engineTopoChanger class.


Error Log.
Code:

Solving cloud sprayCloud
Cloud: sprayCloud
    Current number of parcels      = 0
    Current mass in system          = 0
    Linear momentum                = (0 0 0)
  |Linear momentum|                = 0
    Linear kinetic energy          = 0
    Rotational kinetic energy      = 0
    model1:
        number of parcels added    = 23324
        mass introduced            = 1.40018e-05
    Parcels absorbed into film      = 0
    New film detached parcels      = 0
    Parcel fate (number, mass)
      - escape                      = 0, 0
      - stick                      = 0, 0
    Temperature min/max            = 0, 0
    Mass transfer phase change      = 1.40018e-05
    D10, D32, Dmax (mu)            = 0, 0, 0
    Liquid penetration 95% mass (m) = 0

diagonal:  Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0
DILUPBiCG:  Solving for Ux, Initial residual = 0.01057, Final residual = 2.62337e-06, No Iterations 6
DILUPBiCG:  Solving for Uy, Initial residual = 0.0107857, Final residual = 3.26699e-06, No Iterations 4
DILUPBiCG:  Solving for Uz, Initial residual = 0.0111489, Final residual = 7.23998e-06, No Iterations 5
DILUPBiCG:  Solving for C7H16, Initial residual = 0.000128444, Final residual = 2.77758e-06, No Iterations 1
DILUPBiCG:  Solving for O2, Initial residual = 0.00023513, Final residual = 5.40333e-06, No Iterations 1
DILUPBiCG:  Solving for CO2, Initial residual = 0.00024192, Final residual = 5.66135e-06, No Iterations 1
DILUPBiCG:  Solving for H2O, Initial residual = 0.00024192, Final residual = 5.66135e-06, No Iterations 1
DILUPBiCG:  Solving for h, Initial residual = 0.000348675, Final residual = 8.54449e-06, No Iterations 1
T gas min/max  = 373, 1227.9
DICPCG:  Solving for p, Initial residual = 0.946616, Final residual = 0.0387792, No Iterations 1
diagonal:  Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0
time step continuity errors : sum local = 0.00308543, global = -0.00281121, cumulative = -0.0187543
DICPCG:  Solving for p, Initial residual = 0.122943, Final residual = 4.33585e-07, No Iterations 7
diagonal:  Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0
time step continuity errors : sum local = 6.68342e-08, global = -1.00723e-08, cumulative = -0.0187544
DILUPBiCG:  Solving for epsilon, Initial residual = 0.184601, Final residual = 6.73394e-06, No Iterations 5
DILUPBiCG:  Solving for k, Initial residual = 0.14352, Final residual = 3.70806e-06, No Iterations 5
Mean pressure:1.21075e+06
Mean temperature:1000.98
Mean u':7.30158
ExecutionTime = 2586.16 s  ClockTime = 2589 s

Courant Number mean: 0.0383579 max: 9.37156
deltaT = 2.27587e-08
Crank angle = 58.2433 CA-deg
deltaZ = -9.29923e-08 Piston at:0.0553827
pistonLayerID: 0
Piston layering mode
virtualPistonPosition = 0.0573819, deckHeight = 0.072
clearance: 0.0166174
Piston speed = -4.08602 m/s
Total cylinder volume at CA 58.243256 = sum(V) [0 3 0 0 0 0 0] 7.00003e-05

Solving cloud sprayCloud
Cloud: sprayCloud
    Current number of parcels      = 0
    Current mass in system          = 0
    Linear momentum                = (0 0 0)
  |Linear momentum|                = 0
    Linear kinetic energy          = 0
    Rotational kinetic energy      = 0
    model1:
        number of parcels added    = 23324
        mass introduced            = 1.40018e-05
    Parcels absorbed into film      = 0
    New film detached parcels      = 0
    Parcel fate (number, mass)
      - escape                      = 0, 0
      - stick                      = 0, 0
    Temperature min/max            = 0, 0
    Mass transfer phase change      = 1.40018e-05
    D10, D32, Dmax (mu)            = 0, 0, 0
    Liquid penetration 95% mass (m) = 0

diagonal:  Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0
DILUPBiCG:  Solving for Ux, Initial residual = 0.00465004, Final residual = 6.67201e-07, No Iterations 1
DILUPBiCG:  Solving for Uy, Initial residual = 0.00464643, Final residual = 5.90659e-06, No Iterations 1
DILUPBiCG:  Solving for Uz, Initial residual = 0.00637995, Final residual = 3.58223e-08, No Iterations 1
#0  Foam::error::printStack(Foam::Ostream&) in "/home/rj/OpenFOAM/OpenFOAM-2.2.x/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#1  Foam::sigFpe::sigHandler(int) in "/home/rj/OpenFOAM/OpenFOAM-2.2.x/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#2  in "/lib/x86_64-linux-gnu/libc.so.6"
#3  Foam::chemistryModel<Foam::psiChemistryModel, Foam::sutherlandTransport<Foam::species::thermo<Foam::janafThermo<Foam::perfectGas<Foam::specie> >, Foam::sensibleEnthalpy> > >::solve(double, double) in "/home/rj/OpenFOAM/OpenFOAM-2.2.x/platforms/linux64GccDPOpt/lib/libchemistryModel.so"
#4  Foam::combustionModels::PaSR<Foam::combustionModels::psiChemistryCombustion>::correct() in "/home/rj/OpenFOAM/OpenFOAM-2.2.x/platforms/linux64GccDPOpt/lib/libcombustionModels.so"
#5 
 in "/home/rj/OpenFOAM/OpenFOAM-2.2.x/platforms/linux64GccDPOpt/bin/mySprayEngineFoam"
#6  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#7 
 in "/home/rj/OpenFOAM/OpenFOAM-2.2.x/platforms/linux64GccDPOpt/bin/mySprayEngineFoam"
Floating point exception (core dumped)

fvSolution (I didn't change anything from original sprayEngineFoam)
Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  2.2.0                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    location    "system";
    object      fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

solvers
{
    rho
    {
        solver          PCG;
        preconditioner  DIC;
        tolerance      1e-05;
        relTol          0.1;
    }

    rhoFinal
    {
        $rho;
        tolerance      1e-05;
        relTol          0;
    }

    "(U|h)"
    {
        solver          PBiCG;
        preconditioner  DILU;
        tolerance      1e-05;
        relTol          0.1;
    }

    p
    {
        solver          PCG;
        preconditioner  DIC;
        tolerance      1e-06;
        relTol          0.1;
    }

    pFinal
    {
        $p;
        tolerance      1e-06;
        relTol          0;
    }

    "(U|h)Final"
    {
        $U;
        tolerance      1e-05;
        relTol          0;
    }

    "(k|epsilon)"
    {
        $U;
    }

    "(k|epsilon)Final"
    {
        $UFinal;
    }

    "(Yi|O2|N2|H2O)"
    {
        $UFinal;
    }

    cellMotionUz
    {
        solver          PCG;
        preconditioner  DIC;
        tolerance      1e-08;
        relTol          0;
    }
}

PIMPLE
{
    transonic      no;
    nCorrectors    2;
    nNonOrthogonalCorrectors 0;
    momentumPredictor yes;
}

relaxationFactors
{
    fields
    {
        ".*Final"      1;
    }
    equations
    {
        ".*Final"      1;
    }
}

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

fvScheme (I think I added)
Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  2.2.0                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    location    "system";
    object      fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

ddtSchemes
{
    default        Euler;
}

gradSchemes
{
    default        Gauss linear;
    grad(p)        Gauss linear;
}

divSchemes (added div(meshPhi,p)  Gauss upwind; and div(phid,p)    Gauss upwind; The rest is pretty much the same)
{
    default        none;
    div(phi,U)      Gauss upwind;
    div(phid,p)    Gauss upwind;
    div(phi,h)      Gauss upwind;
    div(meshPhi,p)  Gauss upwind;
    div(phi,K)      Gauss linear;
    div(phi,k)      Gauss upwind;
    div(phi,epsilon) Gauss upwind;
    div(U)          Gauss linear;
    div((muEff*dev2(T(grad(U))))) Gauss linear;
    div(phi,Yi_h)  Gauss upwind;
}

laplacianSchemes
{
    default        Gauss linear orthogonal;
    laplacian(muEff,U) Gauss linear orthogonal;
    laplacian(mut,U) Gauss linear orthogonal;
    laplacian(DkEff,k) Gauss linear orthogonal;
    laplacian(DepsilonEff,epsilon) Gauss linear orthogonal;
    laplacian(DREff,R) Gauss linear orthogonal;
    laplacian((rho*(1|A(U))),p) Gauss linear orthogonal;
    laplacian(alphaEff,h) Gauss linear orthogonal;
}

interpolationSchemes
{
    default        linear;
}

snGradSchemes
{
    default        orthogonal;
}

fluxRequired
{
    default        no;
    p              ;
}


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

ControlDict
Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  2.2.0                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    location    "system";
    object      controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application    mySprayEngineFoam;

startFrom      latestTime;

startTime      -180;

stopAt          endTime;

endTime        180;

deltaT          0.05;

writeControl    adjustableRunTime;

writeInterval  1;

purgeWrite      0;

writeFormat    binary;

writePrecision  6;

writeCompression uncompressed;

timeFormat      general;

timePrecision  6;

adjustTimeStep  yes;

maxCo          0.25;

runTimeModifiable yes;


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


mturcios777 July 4, 2013 12:42

Your max temperature looks like it might be close to auto-ignition. What is the global equivalience ratio at crash time (or are there any combustible gases in the mixture at all?)

RJ87 July 5, 2013 00:31

yep! Combustion at 58 CAD is at its end. Injection starts at -23 CAD and peak at -4.5 CAD with 2504K with 15% oxygen (which is pretty accurate in my opinion after calculating the adiabatic flame temperature)

Now I tried running the simulation at 2X finer mesh at 10X smaller time steps to see what happen. Unfortunately, it has been running for 22 hours straight and i'm just at -15CAD.

Btw, can anyone here able to explain how come the temperature simulated by sprayEngineFoam with engineMesh reaches peak at 3500K while similar set up with engineTopoChangerMesh (layer additon and removal) gives peak combustion temperature at 2500K which is more accurate?

Is it possible that mesh layering and mesh addition and removal able to cause such a big difference?
I think sprayEngineFoam with engineMesh is defective. Because with mesh layering the mesh cell at TDC is ridiculously "flat" after cramping 62mm stroke with 62 cell at BDC to 2mm at TDC. The timestep that close to TDC is in a factor of 10^-9.


All times are GMT -4. The time now is 02:59.