|
[Sponsors] |
April 18, 2017, 13:49 |
cellSet volume in fvOptions
|
#1 |
New Member
Pablo Mtz. Filgueira
Join Date: Apr 2014
Location: Vitoria-Gasteiz
Posts: 25
Rep Power: 12 |
Hi all!
I'll try to explain my case briefly. I want to use a vectorCodedSource fvOptions file, and two of the variables I have to use are volume of a cellSet and volume of each cell in that volume. The cellSet is an small box inside a larger box. I'm having trouble with it as I'm not able to select JUST the cells in my cellSet. This is my fvOptions file: Code:
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 2.3.0 | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class dictionary; location "system"; object fvOptions; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // velocitySource { type vectorCodedSource; active true; selectionMode cellSet; cellSet selectedCells; name velocitySource; vectorCodedSourceCoeffs { fields (U); selectionMode cellSet; cellSet selectedCells; name velocitySource; codeInclude #{ #}; codeCorrect #{ #}; codeAddSup #{ const scalarField& V = mesh_.V(); const vectorField& C = mesh_.C(); scalar V_ = 0.0; forAll(C, i) { V_ += V[i]; } reduce(V_, sumOp<scalar>()); Info<< indent << "- selected " << returnReduce(C.size(), sumOp<label>()) << " cell(s) with volume " << V_ << endl; #}; codeSetValue #{ #}; code #{ $codeCorrect $codeAddSup $codeSetValue #}; } velocitySourceCoeffs { } } // ************************************************************************* // Code:
/*---------------------------------------------------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 4.1 | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ Build : 4.1 Exec : simpleFoam Date : Apr 18 2017 Time : 18:31:45 Host : "pablo-K52Jr" PID : 23352 Case : /home/pablo/misCasosFE/bloques nProcs : 1 sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE). fileModificationChecking : Monitoring run-time modified files using timeStampMaster allowSystemOperations : Allowing user-supplied system call operations // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Create time Create mesh for time = 0 SIMPLE: convergence criteria field U tolerance 0.0001 field p tolerance 0.001 field "(k|epsilon|omega)" tolerance 0.001 Reading field p Reading field U Reading/calculating face flux field phi Selecting incompressible transport model Newtonian Selecting turbulence model type RAS Selecting RAS turbulence model kOmegaSST Selecting patchDistMethod meshWave kOmegaSSTCoeffs { alphaK1 0.85; alphaK2 1; alphaOmega1 0.5; alphaOmega2 0.856; gamma1 0.55555556; gamma2 0.44; beta1 0.075; beta2 0.0828; betaStar 0.09; a1 0.31; b1 1; c1 10; F3 false; } No MRF models present Creating finite volume options from "system/fvOptions" Selecting finite volume options model type vectorCodedSource Source: velocitySource - selecting cells using cellSet selectedCells - selected 90 cell(s) with volume 0.30424486 Starting time loop Time = 1 Using dynamicCode for fvOption:: velocitySource at line 20 in "/home/pablo/misCasosFE/bloques/system/fvOptions.velocitySource.vectorCodedSourceCoeffs" Creating new library in "dynamicCode/velocitySource/platforms/linux64GccDPInt32Opt/lib/libvelocitySource_ba8e2470764f35c431307b63ebef6c2a4b610dc8.so" Invoking "wmake -s libso /home/pablo/misCasosFE/bloques/dynamicCode/velocitySource" '/home/pablo/misCasosFE/bloques/dynamicCode/velocitySource/../platforms/linux64GccDPInt32Opt/lib/libvelocitySource_ba8e2470764f35c431307b63ebef6c2a4b610dc8.so' is up to date. Selecting finite volume options model type velocitySource Source: velocitySource - selected 245760 cell(s) with volume 2400 smoothSolver: Solving for Ux, Initial residual = 0.99999999, Final residual = 0.00056604347, No Iterations 1 smoothSolver: Solving for Uy, Initial residual = 0, Final residual = 0, No Iterations 0 smoothSolver: Solving for Uz, Initial residual = 0, Final residual = 0, No Iterations 0 GAMG: Solving for p, Initial residual = 1, Final residual = 0.069625931, No Iterations 4 time step continuity errors : sum local = 3.3696411e-05, global = -7.2204088e-06, cumulative = -7.2204088e-06 smoothSolver: Solving for omega, Initial residual = 0.00040862179, Final residual = 3.5476531e-07, No Iterations 1 smoothSolver: Solving for k, Initial residual = 1, Final residual = 0.00077749877, No Iterations 1 ExecutionTime = 5.03 s ClockTime = 10 s Time = 2 - selected 245760 cell(s) with volume 2400 smoothSolver: Solving for Ux, Initial residual = 0.26881031, Final residual = 0.00013096311, No Iterations 1 smoothSolver: Solving for Uy, Initial residual = 0.77932555, Final residual = 0.0011502071, No Iterations 1 smoothSolver: Solving for Uz, Initial residual = 0.63576559, Final residual = 0.00068403217, No Iterations 1 GAMG: Solving for p, Initial residual = 0.063295736, Final residual = 0.0031233036, No Iterations 4 time step continuity errors : sum local = 8.1311918e-05, global = -1.6413664e-05, cumulative = -2.3634073e-05 smoothSolver: Solving for omega, Initial residual = 0.0009977819, Final residual = 1.9905606e-06, No Iterations 1 smoothSolver: Solving for k, Initial residual = 0.26501268, Final residual = 0.00026149791, No Iterations 1 ExecutionTime = 7.15 s ClockTime = 12 s I think my error is in the C cell selection, but I'm quite lost. I've read all the documentation available as well as every single post here. Could someone help me please? |
|
April 19, 2017, 03:20 |
|
#2 |
Senior Member
Join Date: Aug 2013
Posts: 407
Rep Power: 16 |
Hi,
My guess is the issue is here: Code:
const scalarField& V = mesh_.V(); const vectorField& C = mesh_.C(); You might want to change/amend that based on this post: Access to cellid in cellSet Hope this helps. Cheers, Antimony |
|
April 19, 2017, 04:20 |
|
#3 | |
New Member
Pablo Mtz. Filgueira
Join Date: Apr 2014
Location: Vitoria-Gasteiz
Posts: 25
Rep Power: 12 |
Quote:
First of all thanks for your quick reply. I have already tested the solutions appearing in that post, but they didn't work as there were many UNDEFINED VARIABLEs. Maybe you know how to define that set of variables. Sent from my HUAWEI VNS-L31 using CFD Online Forum mobile app |
||
April 19, 2017, 05:12 |
|
#4 |
Senior Member
Join Date: Aug 2013
Posts: 407
Rep Power: 16 |
Hi,
I tested it just now and it works fine. Perhaps you could mention which are the variables it says are undefined? If it is the name of your cellSet, then where it says cellSetName_, you need to replace it with "selectedCells" (The double quotes are needed and I assume that the name of the cellSet is selectedCells) A caveat: I tested it out on OF 2.4.x and not on OF 4.1. So I am not sure if that adds to any problems. Hope this helps. Cheers, Antimony |
|
April 19, 2017, 11:37 |
|
#5 | |
New Member
Pablo Mtz. Filgueira
Join Date: Apr 2014
Location: Vitoria-Gasteiz
Posts: 25
Rep Power: 12 |
Quote:
I have tryed using this in an older version of OpenFOAM (3.0x): Code:
codeSetValue #{ cellSet selectedCells(mesh_, cellSetName_); labelList cells = selectedCells.toc(); #}; Code:
codeSetValue #{ cellSet selectedCells(mesh, "myBox"); labelList cells = selectedCells.toc(); #}; Code:
G:/OpenFOAM/Pablo_AMD-3.0.x/run/bloques/system/fvOptions.velocitySource.vectorCodedSourceCoeffs: In member function ‘virtual void Foam::fv::velocitySourceFvOptionvectorSource::setValue(Foam::fvMatrix<Foam::Vector<double> >&, Foam::label)’: G:/OpenFOAM/Pablo_AMD-3.0.x/run/bloques/system/fvOptions.velocitySource.vectorCodedSourceCoeffs:41:1: error: ‘cellSet’ was not declared in this scope G:/OpenFOAM/Pablo_AMD-3.0.x/run/bloques/system/fvOptions.velocitySource.vectorCodedSourceCoeffs:42:31: error: ‘selectedCells’ was not declared in this scope /opt/OpenFOAM/OpenFOAM-3.0.x/wmake/rules/General/transform:8: fallo en las instrucciones para el objetivo 'Make/cygwin64mingw-w64DPInt32Opt/codedFvOptionTemplate.o' It's been a great help, it seems that we are close to the answer |
||
April 19, 2017, 23:12 |
|
#6 |
Senior Member
Join Date: Aug 2013
Posts: 407
Rep Power: 16 |
Hi,
My attempt was in fvOptions. But like I said, I ran it in OF 2.4 and so not sure if there has been a big change after that. So here is the code snippet that I used (which I modified from your original one slightly): Code:
codeAddSup #{ const scalarField& V = mesh_.V(); const vectorField& C = mesh_.C(); cellSet selectedCells(mesh_, "c0"); cells_ = selectedCells.toc(); scalar V_ = 0.0; for(int i=0;i<cells_.size();i++) V_ += V[cells_[i]]; Info<< indent << "- selected " << cells_.size() << " cell(s) with volume " << V_ << endl; #}; Antimony |
|
April 21, 2017, 05:47 |
It works!!!
|
#7 | |
New Member
Pablo Mtz. Filgueira
Join Date: Apr 2014
Location: Vitoria-Gasteiz
Posts: 25
Rep Power: 12 |
Quote:
Thank you so much for your help. Finally, the problem was about OpenFOAM and its well (un)known backwards-compatibility. It works in OF2.4.0. |
||
Tags |
fvoptions, source term, vectorcodedsource |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[blockMesh] edges not aligned with or perpendicular to non-empty directions | ynos | OpenFOAM Meshing & Mesh Conversion | 6 | March 26, 2020 16:02 |
[GAMBIT] Meshing T-pipe | maxpoint | ANSYS Meshing & Geometry | 19 | November 25, 2016 02:33 |
On the damBreak4phaseFine cases | paean | OpenFOAM Running, Solving & CFD | 0 | November 14, 2008 22:14 |
[Commercial meshers] CuBit | t42 | OpenFOAM Meshing & Mesh Conversion | 6 | July 10, 2008 08:51 |
[blockMesh] Axisymmetrical mesh | Rasmus Gjesing (Gjesing) | OpenFOAM Meshing & Mesh Conversion | 10 | April 2, 2007 15:00 |