|
[Sponsors] |
Access and manipulating data from specific cellzone |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
May 3, 2017, 07:18 |
Access and manipulating data from specific cellzone
|
#1 |
New Member
Or Werner
Join Date: Mar 2016
Posts: 7
Rep Power: 10 |
Dear all!
I'm working on a new solver for electromagnetics. I define a material character ('chi'), and read it successfully . Also, volVectorfield 'M' and 'H' are defined. Let's assume a cellzone named "ironCore" is exist in polymesh. The next calculation is required: Code:
1. for all the cells: 1.1 if the current cell is from "ironCore" cellzone: M[ID]=chi*H[ID]. 1.2 otherwise: M[ID]=(0 0 0); Code:
forAll(chi, celli) { M[celli]=chi[celli]*H[celli]; } Code:
for (ii=first_cell_of_ironCore ; ii<number_of_cells_in_ironCore ; ii++) { M[celli]=chi[celli]*H[celli]; } Or. |
|
May 5, 2017, 13:09 |
|
#2 |
Senior Member
Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 21 |
This code might be a point you can start from:
Code:
const fvMesh& mesh = ...; word cellSetName = "yourCellZoneName"; label zoneID = mesh.cellZones().findZoneID(cellSetName); if (zoneID == -1) { FatalErrorIn("yourFunctionName") << "Cannot find cellZone " << cellSetName << endl << "Valid cellZones are " << mesh.cellZones().names() << exit(FatalError); } const labelList& cells = mesh.cellZones()[zoneID]; Info << "Cells in cellzone " << cellSetName << ":" << endl; forAll(cells, i) { const label cell = cells[i]; Info << cell << endl; } |
|
May 10, 2017, 10:28 |
|
#3 |
New Member
Or Werner
Join Date: Mar 2016
Posts: 7
Rep Power: 10 |
Thank you very much Sergei.
about the part of Code:
const label cell = cells[i]; If it is the index in the whole mesh, than it is quite what I need, and I could manage from here. thanks again for helping me, Or. |
|
May 12, 2017, 12:00 |
|
#4 |
Senior Member
Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 21 |
Code:
const label cell = cells[i]; Code:
const volScalarField& T = ... T[cell] = 300.0; |
|
|
|