stfs-tuda / blastamr Goto Github PK
View Code? Open in Web Editor NEWLoad-balanced adaptive mesh refinement libraries from blastFoam ported to ESI OpenFOAM
License: Other
Load-balanced adaptive mesh refinement libraries from blastFoam ported to ESI OpenFOAM
License: Other
hello,I tested two tutorial cases, freeProFlame2D and damBreak2D, and both worked fine in reconstructParMesh.
However, once I use reconstructPar, I will get the following error, as shown in the figure.
It doesn't go wrong from the beginning, it happens sometime in the middle.(actually, freeProFlame2D case was reported error at the first moment)
When I use reconstructPar -latestTime, I can synthesize the data for the last time.
Thanks for your potential help.
For wall bounded flows it may be beneficial to design the boundary layer at the wall and prevent mesh changes in this region, e.g., if the wall distance of Y+>20 should be kept that the selected wall model is working correctly.
Within the codedErrorEstimator it is possible to implement this with a cellSet defined in the topoSetDict in the system folder. However, this requires adding #include "cellSet.H"
to the errorEstimator.H
file.
An example how this can be implemented is shown below:
code #{
// =======================================================================
// IMPORTANT NOTES
// =======================================================================
// this coded error block does not use the scale/normalize function
// The error_ field is normalized within this coded block and
// protected cells created over the topoSet function in OpenFOAM are
// excluded from refinement
//
// To create the set of protected cells use the topoSet function of
// OpenFOAM to create a set of cells e.g.,
//
// system/topoSetDict:
// ...
// actions
// (
// {
// name protectedCells; // Important: DO NOT CHANGE THE NAME
// type cellSet;
// action new;
// source cylinderToCell;
// p1 (0 0 0);
// p2 (0 0 0.0046);
// radius 0.1;
// }
// );
Info<< "---->! custom error estimator !<----" << endl;
error_ = 0.0;
/*
End result must be (error_ is a volScalarField):
- error_ == 1 if the cell needs to be refined
- error_ == 0 if the cell is to be left alone
- error_ == -1 if the vertices of the cell are to be unrefined
*/
const auto& T = mesh_.lookupObject<volVectorField>("U");
error_ == mag(fvc::grad(T)) * dimensionedScalar("one",dimTime,1.0);
// =======================================================================
// Enforce that no near wall cells are refined
// =======================================================================
// check if it is already in the databank
if (!mesh_.foundObject<volScalarField>("error:protectedCells"))
{
Info << "Create initial error:protectedCells"<<endl;
cellSet protectedCellsSet
(
IOobject
(
"protectedCells",
mesh_.pointsInstance()/polyMesh::meshSubDir/"sets",
mesh_,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
volScalarField* protectedCellsPtr = new volScalarField
(
IOobject
(
"error:protectedCells",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh_,
dimensionedScalar("temp",dimless,0)
);
// Transfer ownership to object registry
protectedCellsPtr->store();
volScalarField& protectedCells = *protectedCellsPtr;
// Set the internal values according to the cellSet
forAll(mesh_.C(),celli)
{
if (protectedCellsSet[celli])
protectedCells[celli] = 1.0;
else
protectedCells[celli] = 0.0;
}
}
// =======================================================================
/*
Here is the deal:
- T Gradient is not recomputed if already available - !!
- T will form a diffusive interface, 50% and up of the maxGrad are refined
40%-50% are left alone, and less than 40% are unrefined
- Not well tested, so play with the values.
*/
scalar maxGradT = gMax(error_);
scalar minGradT = gMin(error_);
lowerRefine_ = minGradT + 0.05*(maxGradT-minGradT); // orig: minGradT + 0.5*(maxGradT-minGradT);
upperRefine_ = GREAT;
lowerUnrefine_ = minGradT + 0.01*(maxGradT-minGradT);// orig: minGradT + 0.4*(maxGradT-minGradT);
upperUnrefine_ = GREAT;
// =======================================================================
const volScalarField& protectedCells = mesh_.lookupObject<volScalarField>("error:protectedCells");
// Do not call normalize but do it manually here:
forAll(error_,celli)
{
if (protectedCells[celli] > 0.0)
error_[celli] = 0.0;
else if (error_[celli] < lowerUnrefine_)
error_[celli] = -1.0;
else if (error_[celli] > lowerRefine_)
error_[celli] = 1.0;
else
error_[celli] = 0.0;
}
// error_.correctBoundaryConditions() is called after this code in case you
// need to manipulate boundary values
Info<< "---->! end error estimator !<----" << endl;
#};
Currently the blastAMR model does not work with some turbulence models, in particular the kOmegaSST turbulence model. The reason for this can be found in the balancing of the mesh.
The mesh is balanced in blastAMR using the fvMeshDistribute
class and from it the fvMeshDistribute::distribute()
function. This function calls prior to sending the fields the fvMesh::clearOut()
function (In OpenFOAM v2012 this is in line 2033 of fvMeshDistribute.C).
This function then calls the polyMesh::clearOut()
which itself calls polyMesh::clearAddressing()
, note that the flag isMeshUpdate is set by default to false. Consequently, the meshObject::clear()
is called deleting all TopologicalMeshObject<fvMesh>
objects, which is unfortunately the wallDist class.
This leads then to a pointer error when turbulence::correct()
is called. Particularly for the k-omega SST model, as in kOmegaSSTBase.C
in the F2 function, the square of the y field is required. However, the y field in kOmegaSSTBase was a const reference to the wallDist object created with MeshObject::New()
. Hence, the pointer exception when the underlying wallDist model has been destroyed in the MeshObject::clear()
command.
In fvmeshPolyRefiner, when the hasChanged
check is made, an additional function called updateTurbulenceModel could be implemented. Due to kOmegaSST having a const reference to the y field it is broken and needs to be destroyed. The solution would then be to look up the turbulence model in the object registry, destruct the turbulence model, and reconstruct the turbulence model. I am unsure if one can do this while keeping the autoPtr in createFields valid.
Hey,
when trying to run the tutorial damBreak2D case I get the following problem executing updateMesh. FOAM_CODE_TEMPLATES is set to ../../etc/codeTemplates/dynamicCode, since I'm running the ./Allrun script.
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
Build : 79e353b84e-20201222 OPENFOAM=2012
Arch : "LSB;label=32;scalar=64"
Exec : updateMesh
Date : Nov 09 2023
Time : 09:52:45
Host : gitzzly
PID : 97486
I/O : uncollated
Case : /home/gitzzly/OpenFOAM/gitzzly-v2012/blastAMR/tutorials/damBreak2D
nProcs : 1
trapFpe: Floating point exception trapping enabled (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster (fileModificationSkew 5, maxFileModificationPolls 20)
allowSystemOperations : Allowing user-supplied system call operations
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time
Create mesh for time = 0
Selecting dynamicFvMesh adaptiveFvMesh
Selecting errorEstimator: coded
Using dynamicCode for codedErrorEstimator emulateDelta at line 17 in "/home/gitzzly/OpenFOAM/gitzzly-v2012/blastAMR/tutorials/damBreak2D/constant/dynamicMeshDict"
Could not load "/home/gitzzly/OpenFOAM/gitzzly-v2012/blastAMR/tutorials/damBreak2D/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libemulateDelta_886cd9bdcbf9de5b2d10c8aaa6ee9241d41e170c.so"
/home/gitzzly/OpenFOAM/gitzzly-v2012/blastAMR/tutorials/damBreak2D/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libemulateDelta_886cd9bdcbf9de5b2d10c8aaa6ee9241d41e170c.so: cannot open shared object file: No such file or directory
Invoking wmake libso /home/gitzzly/OpenFOAM/gitzzly-v2012/blastAMR/tutorials/damBreak2D/dynamicCode/emulateDelta
wmake libso /home/gitzzly/OpenFOAM/gitzzly-v2012/blastAMR/tutorials/damBreak2D/dynamicCode/emulateDelta
Ctoo: codedErrorEstimatorTemplate.C
In file included from codedErrorEstimatorTemplate.C:29:
codedErrorEstimatorTemplate.H:38:10: fatal error: errorEstimator.H: No such file or directory
38 | #include "errorEstimator.H"
| ^~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [/home/gitzzly/OpenFOAM/OpenFOAM-v2012/wmake/rules/General/transform:35: Make/linux64GccDPInt32Opt/codedErrorEstimatorTemplate.o] Error 1
--> FOAM FATAL IO ERROR: (openfoam-2012)
Failed wmake "dynamicCode/emulateDelta/platforms/linux64GccDPInt32Opt/lib/libemulateDelta_886cd9bdcbf9de5b2d10c8aaa6ee9241d41e170c.so"
file: /home/gitzzly/OpenFOAM/gitzzly-v2012/blastAMR/tutorials/damBreak2D/constant/dynamicMeshDict at line 17 to 91.
From void Foam::codedBase::createLibrary(Foam::dynamicCode&, const Foam::dynamicCodeContext&) const
in file db/dynamicLibrary/codedBase/codedBase.C at line 201.
FOAM exiting
Regards,
Explore the possibility of using cached field gradients instead of new computations
blastAMR/src/errorEstimators/gradientRange/gradientRange.C
Lines 100 to 105 in d376bfb
@todo
comment in d376bfb.Hello, currently I'm trying to install on the v2206 version, but I always get an error,
like this "no matching function for call to 'Foam::fvMeshDistribute::fvMeshDistribute::fvMeshDistribute'.
I would like to confirm that the current code version is for v2206.
Thanks !
blastAMR gets stuck in an infinite loop in Foam::refinement::consistentRefinement()
because nChanged never becomes zero. The edgeConsistentRefinement()
always returns 1 for the same cell in an infinite loop.
In the case of the tested mesh it was due to cellJLevel > (cellILevel +1)
Note: this was tested with labelsize=64. However tested that the conversion to int for the const cellJLevel
worked correctly.
Not sure what edgeConsistentRefinement()
does and how to fix this issue.
Also an interesting fact is that the problem can be avoided for some time if shortly before the time step is written. Then it runs a bit longer before it gets stuck again.
Hello, I'm back. 😊 Today I'm trying to test out this set of AMR tools that I'm really excited about.
According to my understanding, I can choose any of the error estimation methods provided to finish my case, only the effect is different.
My ideal criterion is this density gradient method. However when I use it, it errors at the first step, as shown in the image.
I can use fieldvalue, codes, etc., and here I provide my dict.
Ask for your guidance. This confuses me so much.
Thank you very much !
There seems to be an error when you use surface sampling together with blastAMR.
When surface sampling is deactivated or if sampling occurs AFTER the first rebalance it works.
When surface sampling is enabled following error occurs:
PIMPLE: iteration 1
---->! custom error estimator !<----
---->! end error estimator !<----
Protecting 2706 cells next to requested boundary patches.
Selected 1625 cells for refinement out of 236952.
Refined from 236952 to 241827 cells.
canBalance(): Maximum imbalance = 122.492939 %
Selecting decompositionMethod scotch [64]
Selecting decompositionConstraint polyRefinement
polyRefinement : setting constraints to preserve refinement history
polyRefinement : reading fvMeshPolyRefiner from time "3.87719e-06"
2D case detected. Adding prismatic2DRefinement topology modifier
polyRefinement : reading fvMeshPolyRefiner from time "3.87719e-06"
2D case detected. Adding prismatic2DRefinement topology modifier
1
Maximum imbalance = 122.492939 %
polyRefinement : reading fvMeshPolyRefiner from time "3.87719e-06"
2D case detected. Adding prismatic2DRefinement topology modifier
polyRefinement : reading fvMeshPolyRefiner from time "3.87719e-06"
2D case detected. Adding prismatic2DRefinement topology modifier
Mapping the fields ...
Distributing the mesh ...
Successfully distributed mesh
New max imbalance: 0.967220368%
[47] [61]
[61]
[61] --> FOAM FATAL ERROR: (openfoam-2012)
[61] Cannot dereference nullptr at index 10 in range [0,10)
[61]
[61]
[61] From const T& Foam::UPtrList<T>::operator[](Foam::label) const [with T = Foam::polyPatch; Foam::label = long int]
[61] in file /home/itvjg/OpenFOAM/OpenFOAM-v2012-int64/src/OpenFOAM/lnInclude/UPtrListI.H at line 218.
[61]
FOAM parallel run aborting
[61]
[61] #0 Foam::error::printStack(Foam::Ostream&)[33] #0 [35] #0 [36] #0 [37] #0 [46] #0 Foam::error::printStack(Foam::Ostream&)[59] #0 Foam::error::printStack(Foam::Ostream&)[60] #0 Foam::error::printStack(Foam::Ostream&)[62] #0 Foam::error::printStack(Foam::Ostream&)[63] #0 Foam::error::printStack(Foam::Ostream&)[32] #0 Foam::error::printStack(Foam::Ostream&)[12] #0 Foam::error::printStack(Foam::Ostream&)[14] #0 Foam::error::printStack(Foam::Ostream&)[17] #0 Foam::error::printStack(Foam::Ostream&)[18] #0 Foam::error::printStack(Foam::Ostream&)[19] #0 Foam::error::printStack(Foam::Ostream&)[20] #0 Foam::error::printStack(Foam::Ostream&)[21] #0 Foam::error::printStack(Foam::Ostream&)[24] #0 Foam::error::printStack(Foam::Ostream&)[25] #0 Foam::error::printStack(Foam::Ostream&)[26] #0 Foam::error::printStack(Foam::Ostream&)[31] #0 Foam::error::printStack(Foam::Ostream&)Foam::error::printStack(Foam::Ostream&)Foam::error::printStack(Foam::Ostream&)Foam::error::printStack(Foam::Ostream&)Foam::error::printStack(Foam::Ostream&)[53] #0 Foam::error::printStack(Foam::Ostream&)[0] #0 Foam::error::printStack(Foam::Ostream&)[4] #0 Foam::error::printStack(Foam::Ostream&)[5] #0 Foam::error::printStack(Foam::Ostream&)[8] #0 Foam::error::printStack(Foam::Ostream&)[9] #0 Foam::error::printStack(Foam::Ostream&)
[47]
[47] --> FOAM FATAL ERROR: (openfoam-2012)
[47] Cannot dereference nullptr at index 10 in range [0,10)
[47]
[47]
[47] From const T& Foam::UPtrList<T>::operator[](Foam::label) const [with T = Foam::polyPatch; Foam::label = long int]
[47] in file /home/itvjg/OpenFOAM/OpenFOAM-v2012-int64/src/OpenFOAM/lnInclude/UPtrListI.H at line 218.
[47]
FOAM parallel run aborting
[47]
[47] #0 Foam::error::printStack(Foam::Ostream&) at ??:?
[46] #1 Foam::sigSegv::sigHandler(int) at ??:?
at ??:?
[60] #1 Foam::sigSegv::sigHandler(int) at ??:?
[62] #1 Foam::sigSegv::sigHandler(int) at ??:?
[63] #1 Foam::sigSegv::sigHandler(int) at ??:?
[61] #1 Foam::error::exitOrAbort(int, bool) at ??:?
[36] #1 Foam::sigSegv::sigHandler(int) at ??:?
[37] #1 Foam::sigSegv::sigHandler(int) at ??:?
at ??:?
at ??:?
[59] #1 Foam::sigSegv::sigHandler(int) at ??:?
[53] #1 Foam::sigSegv::sigHandler(int)[35] #1 Foam::sigSegv::sigHandler(int)[32] #1 Foam::sigSegv::sigHandler(int)[33] #1 Foam::sigSegv::sigHandler(int) at ??:?
[9] #1 Foam::sigSegv::sigHandler(int) at ??:?
[8] #1 Foam::sigSegv::sigHandler(int) at ??:?
[24] #1 Foam::sigSegv::sigHandler(int) at ??:?
[25] #1 Foam::sigSegv::sigHandler(int) at ??:?
[26] #1 Foam::sigSegv::sigHandler(int) at ??:?
[4] #1 Foam::sigSegv::sigHandler(int) at ??:?
[12] #1 Foam::sigSegv::sigHandler(int) at ??:?
[14] #1 Foam::sigSegv::sigHandler(int) at ??:?
at ??:?
at ??:?
at ??:?
[20] #1 Foam::sigSegv::sigHandler(int) at ??:?
[21] #1 Foam::sigSegv::sigHandler(int) at ??:?
at ??:?
[5] #1 at ??:?
[17] #1 Foam::sigSegv::sigHandler(int)[18] #1 Foam::sigSegv::sigHandler(int)[19] #1 Foam::sigSegv::sigHandler(int)Foam::sigSegv::sigHandler(int) at ??:?
[0] #1 Foam::sigSegv::sigHandler(int)[31] #1 Foam::sigSegv::sigHandler(int)[47] #1 Foam::error::exitOrAbort(int, bool) at ??:?
[36] #2 ? at ??:?
[60] #2 ? at ??:?
[37] #2 ? at ??:?
[63] #2 ? at ??:?
[61] #2 void Foam::fvMeshBalance::correctBoundaries<Foam::GeometricField<double, Foam::pointPatchField, Foam::pointMesh> >() at ??:?
at ??:?
[35] #2 ? at ??:?
[32] #2 ? at ??:?
[33] #2 ?[62] #2 ? at ??:?
[46] #2 ? at ??:?
[53] #2 ? at ??:?
[59] #2 ? at ??:?
[26] #2 ? at ??:?
[8] #2 ? at ??:?
[24] #2 ? at ??:?
[25] #2 ? at ??:?
[12] #2 ? at ??:?
[14] #2 ? at ??:?
[20] #2 ? at ??:?
[21] #2 ? at ??:?
[4] #2 ? in /lib/x86_64-linux-gnu/libc.so.6
[37] #3 __dynamic_cast at ??:?
in /lib/x86_64-linux-gnu/libc.so.6
at ??:?
[18] #2 ? at ??:?
[17] #2 ? at ??:?
[19] #2 ?[5] #2 ? at ??:?
[63] #3 __dynamic_cast in /lib/x86_64-linux-gnu/libc.so.6
[60] #3 __dynamic_cast[47] #2 void Foam::fvMeshBalance::correctBoundaries<Foam::GeometricField<double, Foam::pointPatchField, Foam::pointMesh> >() in /lib/x86_64-linux-gnu/libc.so.6
[62] #3 __dynamic_cast in /lib/x86_64-linux-gnu/libc.so.6
[32] #3 __dynamic_cast at ??:?
[61] #3 Foam::fvMeshBalance::distribute() in /lib/x86_64-linux-gnu/libc.so.6
[33] #3 __dynamic_cast in /lib/x86_64-linux-gnu/libc.so.6
[35] #3 __dynamic_cast in /lib/x86_64-linux-gnu/libc.so.6
[46] #3 __dynamic_cast in /lib/x86_64-linux-gnu/libc.so.6
[36] #3 __dynamic_cast at ??:?
[9] #2 ? at ??:?
[0] #2 ? at ??:?
[31] #2 ? in /lib/x86_64-linux-gnu/libc.so.6
[53] #3 __dynamic_cast in /lib/x86_64-linux-gnu/libc.so.6
[59] #3 __dynamic_cast in /lib/x86_64-linux-gnu/libc.so.6
[25] #3 __dynamic_cast in /lib/x86_64-linux-gnu/libc.so.6
[26] #3 __dynamic_cast in /lib/x86_64-linux-gnu/libc.so.6
[21] #3 __dynamic_cast in /lib/x86_64-linux-gnu/libc.so.6
[12] #3 __dynamic_cast in /lib/x86_64-linux-gnu/libc.so.6
[14] #3 __dynamic_cast in /lib/x86_64-linux-gnu/libc.so.6
[20] #3 __dynamic_cast in /lib/x86_64-linux-gnu/libc.so.6
in /lib/x86_64-linux-gnu/libc.so.6
[8] #3 __dynamic_cast in /lib/x86_64-linux-gnu/libc.so.6
[4] #3 __dynamic_cast in /lib/x86_64-linux-gnu/libc.so.6
[17] #[18] #3 __dynamic_cast3 __dynamic_cast in /lib/x86_64-linux-gnu/libstdc++.so.6
[37] #4 void Foam::fvMeshBalance::correctBoundaries<Foam::GeometricField<double, Foam::pointPatchField, Foam::pointMesh> >() in /lib/x86_64-linux-gnu/libstdc++.so.6
in /lib/x86_64-linux-gnu/libstdc++.so.6
[63] #4 void Foam::fvMeshBalance::correctBoundaries<Foam::GeometricField<double, Foam::pointPatchField, Foam::pointMesh> >()[60] #4 void Foam::fvMeshBalance::correctBoundaries<Foam::GeometricField<double, Foam::pointPatchField, Foam::pointMesh> >() in /lib/x86_64-linux-gnu/libc.so.6
[24] #3 __dynamic_cast in /lib/x86_64-linux-gnu/libc.so.6
in /lib/x86_64-linux-gnu/libc.so.6
[19] #3 __dynamic_cast[5] #3 __dynamic_cast in /lib/x86_64-linux-gnu/libstdc++.so.6
[62] #4 void Foam::fvMeshBalance::correctBoundaries<Foam::GeometricField<double, Foam::pointPatchField, Foam::pointMesh> >() in /lib/x86_64-linux-gnu/libstdc++.so.6
[36] #4 void Foam::fvMeshBalance::correctBoundaries<Foam::GeometricField<double, Foam::pointPatchField, Foam::pointMesh> >() in /lib/x86_64-linux-gnu/libstdc++.so.6
[32] #4 void Foam::fvMeshBalance::correctBoundaries<Foam::GeometricField<double, Foam::pointPatchField, Foam::pointMesh> >() in /lib/x86_64-linux-gnu/libstdc++.so.6
[33] #4 void Foam::fvMeshBalance::correctBoundaries<Foam::GeometricField<double, Foam::pointPatchField, Foam::pointMesh> >() at ??:?
[47] #3 Foam::fvMeshBalance::distribute() in /lib/x86_64-linux-gnu/libstdc++.so.6
[35] #4 void Foam::fvMeshBalance::correctBoundaries<Foam::GeometricField<double, Foam::pointPatchField, Foam::pointMesh> >() in /lib/x86_64-linux-gnu/libstdc++.so.6
[46] #4 void Foam::fvMeshBalance::correctBoundaries<Foam::GeometricField<double, Foam::pointPatchField, Foam::pointMesh> >() at ??:?
Compiling with label size 64 causes an error at:
fvMeshRefiner/fvMeshPolyRefiner/prismatic2DRefinement/prismatic2DRefinement.C:710:5: error: no matching function for call to ‘Foam::syncTools::syncEdgeList(const Foam::polyMesh&, Foam::labelList&, Foam::maxEqOp<long int>, int)’
709 | syncTools::syncEdgeList
| ~~~~~~~~~~~~~~~~~~~~~~~
710 | (
| ^
711 | mesh_,
| ~~~~~~
712 | edgeMidPoint,
| ~~~~~~~~~~~~~
713 | maxEqOp<label>(),
| ~~~~~~~~~~~~~~~~~
714 | -1
| ~~
715 | );
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.