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

[Other] Multiple Grid Algorithms

Register Blogs Community New Posts Updated Threads Search

Like Tree4Likes
  • 1 Post By akidess
  • 1 Post By peterhess
  • 1 Post By akidess
  • 1 Post By peterhess

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 5, 2018, 02:56
Default Multiple Grid Algorithms
  #1
Senior Member
 
krishna kant
Join Date: Feb 2016
Location: Hyderabad, India
Posts: 133
Rep Power: 10
kk415 is on a distinguished road
I want to make a solver in openfoam in which some variables are defined in one grid and others are in different grid. Also the variables will be coupled to each other. Is it possible to make such solver in openFoam. And I need some suggestion to begin in this direction.
kk415 is offline   Reply With Quote

Old   January 5, 2018, 04:29
Default
  #2
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30
akidess will become famous soon enough
Have a look at how chtMultiRegionFoam handles multiple meshes and try to build up your solution from there.
kk415 likes this.
__________________
*On twitter @akidTwit
*Spend as much time formulating your questions as you expect people to spend on their answer.
akidess is offline   Reply With Quote

Old   January 5, 2018, 05:27
Default
  #3
Senior Member
 
krishna kant
Join Date: Feb 2016
Location: Hyderabad, India
Posts: 133
Rep Power: 10
kk415 is on a distinguished road
Thanks for your help
kk415 is offline   Reply With Quote

Old   January 5, 2018, 10:25
Default
  #4
Senior Member
 
Peter Hess
Join Date: Apr 2011
Location: Austria
Posts: 250
Rep Power: 17
peterhess is on a distinguished road
Hello!

Hier is a good place where you could start:

http://openfoamwiki.net/index.php/Ho...ure_to_icoFoam

In:

incompressible/pimpleDyMFoam/wingMotion

You will find how to mapFields example.

Using mapFields you are able to export Data/Fields from one Mesh to other!

The Meshes must not be identical!



Regards

Peter
kk415 likes this.
peterhess is offline   Reply With Quote

Old   January 8, 2018, 09:25
Default
  #5
Senior Member
 
krishna kant
Join Date: Feb 2016
Location: Hyderabad, India
Posts: 133
Rep Power: 10
kk415 is on a distinguished road
Sir

First of all thanks for your suggestions. I find that chtMultiRegionFoam is one solver in which we use two different grids one for solid region and one for fluid region. They also create different fields for each regions.


My problem is I am unable to get how they are differentiating in regions. They are creating only one block and then using toposet to define different region. But I still don't get how they identify which one is solid and which one is fluid.


Also I can't use toposet to differentiate the regions in my problem because the region are same in both grids in my case. Only thing is one grid will be coarse and other will be fine.
kk415 is offline   Reply With Quote

Old   January 8, 2018, 09:43
Default
  #6
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30
akidess will become famous soon enough
Quote:
Originally Posted by kk415 View Post

My problem is I am unable to get how they are differentiating in regions. They are creating only one block and then using toposet to define different region. But I still don't get how they identify which one is solid and which one is fluid.


It's user specified via regionProperties.


Quote:
Originally Posted by kk415 View Post
Also I can't use toposet to differentiate the regions in my problem because the region are same in both grids in my case. Only thing is one grid will be coarse and other will be fine.
Yes you can, because topoSet doesn't care where your grids are located or if they overlap. Anyway, it sounds like you were expecting you could use chtMultiRegionFoam without any changes, which of course is not true. It just shows you some useful machinery to write a solver that deals with multiple meshes. In chtMultiRegionFoam those meshes are coupled at the boundaries, in your case you'll need to add a mechanism to interpolate the values from one mesh to another.
kk415 likes this.
__________________
*On twitter @akidTwit
*Spend as much time formulating your questions as you expect people to spend on their answer.
akidess is offline   Reply With Quote

Old   January 8, 2018, 10:00
Default
  #7
Senior Member
 
Peter Hess
Join Date: Apr 2011
Location: Austria
Posts: 250
Rep Power: 17
peterhess is on a distinguished road
Hello kk415!

You need to define which regions are solid and which are flluid in constant/regionsPeoperties as akidess mentioned!

Hier is a working example of chtMultiRegionSimpleFoam.

The regions are drawen in freecad and exported as stl, then defined by kind in regionsPeoperties.

I hope it helps to understand the steps.

Regards

Peter
Attached Files
File Type: gz LUM.tar.gz (10.4 KB, 5 views)
kk415 likes this.

Last edited by peterhess; January 8, 2018 at 12:31.
peterhess is offline   Reply With Quote

Old   May 8, 2018, 06:43
Default
  #8
Senior Member
 
krishna kant
Join Date: Feb 2016
Location: Hyderabad, India
Posts: 133
Rep Power: 10
kk415 is on a distinguished road
Hi Peter and Anton,

I make a model for solving different PDE in different grids using mapField utility of OpenFoam. This work as following:

#!/bin/sh

cd testFoam_cavity; //case folder of coarse mesh
blockMesh;
for ((i=0;i < 100;i=i+1)) {
cd ../testFoam_cavityfine_scalar //case folder of fine mesh
mapFields ../testFoam_cavity -consistent
cd ../testFoam_cavity
testFoam //solver same as icoFoam i.e. solving NS equation and energy equation is commented
cd ../testFoam_cavityfine_scalar
testFoamScalar //solver for energy equation and NS equation is commented
cd ../testFoam_cavity
mapFields ../testFoam_cavityfine_scalar -consistent
}

It works fine in terms of result but the way is inefficient as It requires reading mesh too many times in one timeStep. Any suggestions to improve it.

Thanks
kk415 is offline   Reply With Quote

Old   May 25, 2018, 06:47
Default
  #9
Senior Member
 
krishna kant
Join Date: Feb 2016
Location: Hyderabad, India
Posts: 133
Rep Power: 10
kk415 is on a distinguished road
Hi

I am trying to solve a cavity problem in which NS equations are solved in coarser grid and Energy equation is solved in finer grid. I am trying to interpolate fields in between the meshes similar to mapFields.c

My testFoam.c file is as following

/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 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
icoFoam

Description
Transient solver for incompressible, laminar flow of Newtonian fluids.

\*---------------------------------------------------------------------------*/

#include "fvCFD.H"
#include "regionProperties.H"
#include "pisoControl.H"
#include "meshToMesh0.H"
#include "MapMeshes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

int main(int argc, char *argv[])
{
#define NO_CONTROL
#define CREATE_MESH createMeshesPostProcess.H
#include "postProcess.H"

#include "setRootCase.H"
#include "createTime.H"
#include "createMeshes.H"
#include "createFields.H"
#include "initContinuityErrs.H"
#include "createTimeControls.H"
#include "readSolidTimeControls.H"
#include "setInitialMultiRegionDeltaT.H"

meshToMesh0:rder mapOrder = meshToMesh0::INTERPOLATE;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

Info<< "\nStarting time loop\n" << endl;

while (runTime.loop())
{
#include "readTimeControls.H"
#include "readSolidTimeControls.H"
#include "setMultiRegionDeltaT.H"
Info<< "Time = " << runTime.timeName() << nl << endl;

//#include "CourantNo.H" //?

forAll(fluidRegions, i)
{
Info<< "\nSolving for fluid region "
<< fluidRegions[i].name() << endl;
pisoControl piso(fluidRegions[i]);
#include "setRegionFluidFields.H"
// Momentum predictor

fvVectorMatrix UEqn
(
fvm::ddt(U)
+ fvm::div(phi, U)
- fvm::laplacian(nu, U)
);

if (piso.momentumPredictor())
{
solve(UEqn == -fvc::grad(p));
}

// --- PISO loop
while (piso.correct())
{
volScalarField rAU(1.0/UEqn.A());
volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p));
surfaceScalarField phiHbyA
(
"phiHbyA",
fvc::flux(HbyA)
+ fvc::interpolate(rAU)*fvc::ddtCorr(U, phi)
);

adjustPhi(phiHbyA, U, p);

// Update the pressure BCs to ensure flux consistency
constrainPressure(p, U, phiHbyA, rAU);

// Non-orthogonal pressure corrector loop
while (piso.correctNonOrthogonal())
{
// Pressure corrector

fvScalarMatrix pEqn
(
fvm::laplacian(rAU, p) == fvc::div(phiHbyA)
);

pEqn.setReference(pRefCell, pRefValue);

pEqn.solve(fluidRegions[i].solver(p.select(piso.finalInnerIter())));

if (piso.finalNonOrthogonalIter())
{
phi = phiHbyA - pEqn.flux();
}
}

// #include "continuityErrs.H"

U = HbyA - rAU*fvc::grad(p);
U.correctBoundaryConditions();
}

} //all fluid regions
//subtract= false;

//Interpolation from coarser to finer mesh
MapConsistentMesh<eqOp>(fluidRegions[0], solidRegions[0], mapOrder);


forAll(solidRegions, i)
{
Info<< "\nSolving for solid region "
<< solidRegions[i].name() << endl;
#include "setRegionSolidFields.H"
//add these lines...
fvScalarMatrix TEqn
(
fvm::ddt(T)
+ fvm::div(phi, T)
- fvm::laplacian(DT, T)
);

TEqn.solve();
//done adding lines...
} //all solid regions

//Interpolation from finer to coarser mesh
MapConsistentMesh<eqOp>(solidRegions[0], fluidRegions[0], mapOrder);

runTime.write();

Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}

Info<< "End\n" << endl;

return 0;
}


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

I am getting this error

[Rajesh@DRDO-Raja testFoam]$ wmake
/home/Rajesh/OpenFOAM/OpenFOAM-4.1/applications/solvers/heatTransfer/testFoam
g++ -std=c++0x -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=64 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -O3 -DNoRepository -ftemplate-depth-100 -I. -I./fluid -I./solid -I./include -I/home/Rajesh/OpenFOAM/OpenFOAM-4.1/src/meshTools/lnInclude -I/home/Rajesh/OpenFOAM/OpenFOAM-4.1/src/finiteVolume/lnInclude -I/home/Rajesh/OpenFOAM/OpenFOAM-4.1/src/regionModels/regionModel/lnInclude -I/home/Rajesh/OpenFOAM/OpenFOAM-4.1/src/sampling/lnInclude -I/home/Rajesh/OpenFOAM/OpenFOAM-4.1/src/lagrangian/basic/lnInclude -IlnInclude -I. -I/home/Rajesh/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude -I/home/Rajesh/OpenFOAM/OpenFOAM-4.1/src/OSspecific/POSIX/lnInclude -fPIC -c testFoam.C -o /home/Rajesh/OpenFOAM/OpenFOAM-4.1/platforms/linux64GccDPInt64Opt/applications/solvers/heatTransfer/testFoam/testFoam.o
In file included from testFoam.C:73:0:
./fluid/setRegionFluidFields.H: In function ‘int main(int, char**)’:
./fluid/setRegionFluidFields.H:3:21: warning: unused variable ‘T’ [-Wunused-variable]
volScalarField& T = TFluid[i];
^
In file included from testFoam.C:142:0:
./solid/setRegionSolidFields.H:5:21: warning: unused variable ‘U’ [-Wunused-variable]
volVectorField& U = USolid[i];
^
In file included from testFoam.C:50:0:
/home/Rajesh/OpenFOAM/OpenFOAM-4.1/src/finiteVolume/lnInclude/createTimeControls.H:35:8: warning: variable ‘maxCo’ set but not used [-Wunused-but-set-variable]
scalar maxCo =
^
/home/Rajesh/OpenFOAM/OpenFOAM-4.1/src/finiteVolume/lnInclude/createTimeControls.H:38:8: warning: variable ‘maxDeltaT’ set but not used [-Wunused-but-set-variable]
scalar maxDeltaT =
^
g++ -std=c++0x -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=64 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -O3 -DNoRepository -ftemplate-depth-100 -I. -I./fluid -I./solid -I./include -I/home/Rajesh/OpenFOAM/OpenFOAM-4.1/src/meshTools/lnInclude -I/home/Rajesh/OpenFOAM/OpenFOAM-4.1/src/finiteVolume/lnInclude -I/home/Rajesh/OpenFOAM/OpenFOAM-4.1/src/regionModels/regionModel/lnInclude -I/home/Rajesh/OpenFOAM/OpenFOAM-4.1/src/sampling/lnInclude -I/home/Rajesh/OpenFOAM/OpenFOAM-4.1/src/lagrangian/basic/lnInclude -IlnInclude -I. -I/home/Rajesh/OpenFOAM/OpenFOAM-4.1/src/OpenFOAM/lnInclude -I/home/Rajesh/OpenFOAM/OpenFOAM-4.1/src/OSspecific/POSIX/lnInclude -fPIC -Xlinker --add-needed -Xlinker --no-as-needed /home/Rajesh/OpenFOAM/OpenFOAM-4.1/platforms/linux64GccDPInt64Opt/applications/solvers/heatTransfer/testFoam/testFoam.o -L/home/Rajesh/OpenFOAM/OpenFOAM-4.1/platforms/linux64GccDPInt64Opt/lib \
-lmeshTools -lfiniteVolume -lregionModels -lsampling -llagrangian -lgenericPatchFields -lOpenFOAM -ldl \
-lm -o /home/Rajesh/OpenFOAM/OpenFOAM-4.1/platforms/linux64GccDPInt64Opt/bin/testFoam
/home/Rajesh/OpenFOAM/OpenFOAM-4.1/platforms/linux64GccDPInt64Opt/applications/solvers/heatTransfer/testFoam/testFoam.o: In function `void Foam::MapConsistentMesh<Foam::eqOp>(Foam::fvMesh const&, Foam::fvMesh const&, Foam::meshToMesh0:rder const&)':
testFoam.C.text._ZN4Foam17MapConsistentMeshINS_4 eqOpEEEvRKNS_6fvMeshES4_RKNS_11meshToMesh05orderE[_ZN4Foam17MapConsistentMeshINS_4eqOpEEEvRKNS_6fvMe shES4_RKNS_11meshToMesh05orderE]+0x2b3): undefined
reference to `Foam::mapLagrangian(Foam::meshToMesh0 const&)'
collect2: error: ld returned 1 exit status
make: *** [/home/Rajesh/OpenFOAM/OpenFOAM-4.1/platforms/linux64GccDPInt64Opt/bin/testFoam] Error 1

The Option file is as following:

# 1 "Make/options"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "Make/options"

EXE_INC = -I. -I./fluid -I./solid -I./include -I$(LIB_SRC)/meshTools/lnInclude -I$(LIB_SRC)/finiteVolume/lnInclude -I$(LIB_SRC)/regionModels/regionModel/lnInclude -I$(LIB_SRC)/sampling/lnInclude -I$(LIB_SRC)/lagrangian/basic/lnInclude

EXE_LIBS = -lmeshTools -lfiniteVolume -lregionModels -lsampling -llagrangian -lgenericPatchFields

Any suggestion how to tackle the problem further. In case I am not clear in something then let me know.

Thanks
kk415 is offline   Reply With Quote

Old   May 25, 2018, 11:16
Default
  #10
Senior Member
 
krishna kant
Join Date: Feb 2016
Location: Hyderabad, India
Posts: 133
Rep Power: 10
kk415 is on a distinguished road
It seems the problem is I can't get IO object list correctly. So I am attaching the create fluid and solid field file and the mapping file in which IO object list is required.

MapMeshes.H

createFluidFields.H

createSolidFields.H
kk415 is offline   Reply With Quote

Reply


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
Grid Check Script pdp.aero SU2 2 April 23, 2015 02:54
MapFields to New Grid For Extreme Grid Deformations due to Body Motion albcem OpenFOAM 0 May 5, 2009 15:17
Grid Adaptation Suresh FLUENT 0 October 15, 2003 14:18
GRID TO GRID INTERPOLATION in FLUENT calogero FLUENT 3 June 4, 2003 09:32
Numerical methods for discontinuous grid interfaces? Hansong Hang Main CFD Forum 12 September 16, 1998 23:26


All times are GMT -4. The time now is 09:00.