CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Create dynamic cellSet (http://www.cfd-online.com/Forums/openfoam-programming-development/100535-create-dynamic-cellset.html)

Pedro24 April 26, 2012 12:34

Create dynamic cellSet
 
Hello,

I want to create a dynamic set of cells, i.e., which evolves with time.

Example :

I created a Bounding box ( xmin(t), ymin(t) ) ( xmax(t), ymax(t) )

With the function boxToCell, I can define a set "myCellSet" which contains all the cells within the Bounding box (using the "setSet" tools). But I want that this set of cells evolves with time which means that i must include this operation in my solver "myInterFoam.C" (for example) :

At the timestep 1, "myCellSet" contains all cells in (xmin(1) ymin(1)) (xmax(1) ymax(1)

At the timestep 2, "myCellSet" contains all cells in (xmin(2) ymin(2)) (xmax(2) ymax(2))

....

My problem is that i created successfully a "dynamic" bounding box but i can't create a topoSet containing the cell labels of my bounding box.

How can I create at each time step this topoSet ?

Thank you

Pierre

Pedro24 May 4, 2012 03:45

Hi :) ,

I finally found how to create a cellSet (and the cellZone associated) dynamically in a box which evolves with time. Here is my code :

// size of the box where minPoint and maxPoint evolves with time
const point minPoint(xmin,ymin,zmin);
const point maxPoint(xmax,ymax,zmax);

// IStringStream generation
string buffer = "(";
string aux = " ";
std::ostringstream sXmin,sYmin,sZmin,sXmax,sYmax,sZmax;
sXmin << xmin;
sYmin << ymin;
sZmin << zmin;
sXmax << xmax;
sYmax << ymax;
sZmax << zmax;
buffer = buffer + sXmin.str() + aux + sYmin.str() + aux + sZmin.str();
aux = ") (";
buffer = buffer + aux;
aux = " ";
buffer = buffer + sXmax.str()+ aux + sYmax.str() + aux + sZmax.str() ;
aux = ")";
buffer = buffer + aux;
IStringStream isString(buffer);

// cellSet creation
const globalMeshData& parData = mesh.globalData();
label typSize =
max
(
parData.nTotalCells(),
max
(
parData.nTotalFaces(),
parData.nTotalPoints()
)
);

const word setType = "cellSet";
const word setName = "myVofSet";
autoPtr<topoSet> currentSetPtr = topoSet::New(setType, mesh, setName, typSize);
topoSet& currentSet = currentSetPtr();

// boxToCell creation
word sourceType="boxToCell";
autoPtr<topoSetSource> setSource
(
topoSetSource::New
(
sourceType,
mesh,
isString
)
);

// Application of the topoSetSource to "myVofSet"
topoSetSource::setAction action = topoSetSource::toAction("new");
setSource().applyToSet(action, currentSet);


// cellZone creation
Info<< "Adding set " << currentSet.name() << " as a cellZone." << endl;
SortableList<label> cellLabels(currentSet.toc());
label sz = mesh.cellZones().size();
mesh.cellZones().setSize(sz+1);
mesh.cellZones().set
(
sz,
new cellZone
(
currentSet.name(),
cellLabels,
sz,
mesh.cellZones()
)
);


Now, I have a "dynamic" cellZone and I want to extract a submesh of all cells in the cellZone. Do you know if is it possible ?

Thanks,

Pierre


All times are GMT -4. The time now is 18:56.