Chrisi1984 |
August 3, 2010 08:42 |
looping over cells
Hi all,
I am using the chtMultiRegionSimpleFoam solver.
I want to define different properties (cp, K, rho) for different zones of my solid.
Therefor I edited the "solveSolid.H"-file in this way:
Quote:
{
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
fvScalarMatrix tEqn
(
-fvm::laplacian(K, T)
);
tEqn.relax();
eqnResidual = tEqn.solve().initialResidual();
maxResidual = max(eqnResidual, maxResidual);
}
Info<< "Min/max T:" << min(T).value() << ' '
<< max(T).value() << endl;
//////////////////////////////////////
forAll(solidRegions[i].cellZones(), iZone) //loop over all cellZones
{
if (solidRegions[i].cellZones()[iZone].name() == "s-oc") //with "bla" being name of porous cellZone
{
forAll(solidRegions[i].cellZones()[iZone], iCell) //loop over all cells in Zone
{
cp=cp0_1+cp1_1*T+cp2_1*T*T;
K=K0_1+K1_1*T+K2_1*T*T;
rho=rho_1;
}
}
if (solidRegions[i].cellZones()[iZone].name() == "s-outer-jacket") //with "bla" being name of porous cellZone
{
forAll(solidRegions[i].cellZones()[iZone], iCell) //loop over all cells in Zone
{
cp=cp0_1+cp1_1*T+cp2_1*T*T;
K=K0_1+K1_1*T+K2_1*T*T;
rho=rho_1;
}
}
if (solidRegions[i].cellZones()[iZone].name() == "s-insu-mat") //with "bla" being name of porous cellZone
{
forAll(solidRegions[i].cellZones()[iZone], iCell) //loop over all cells in Zone
{
cp=cp0_3;
K=K0_3+K1_3*T+K2_3*T*T;
rho=rho_2;
}
}
if (solidRegions[i].cellZones()[iZone].name() == "s-inner-jacket") //with "bla" being name of porous cellZone
{
forAll(solidRegions[i].cellZones()[iZone], iCell) //loop over all cells in Zone
{
cp=cp0_1+cp1_1*T+cp2_1*T*T;
K=K0_1+K1_1*T+K2_1*T*T;
rho=rho_1;
}
}
if (solidRegions[i].cellZones()[iZone].name() == "s-sm2") //with bla being name of porous cellZone
{
forAll(solidRegions[i].cellZones()[iZone], iCell) //loop over all cells in Zone
{
cp=cp0_3;
K=K0_2+K1_2*T+K2_2*T*T;
rho=rho_2;
}
}
if (solidRegions[i].cellZones()[iZone].name() == "s-sm1") //with bla being name of porous cellZone
{
forAll(solidRegions[i].cellZones()[iZone], iCell) //loop over all cells in Zone
{
cp=cp0_3;
K=K0_2+K1_2*T+K2_2*T*T;
rho=rho_2;
}
}
if (solidRegions[i].cellZones()[iZone].name() == "s-ic-oj") //with bla being name of porous cellZone
{
forAll(solidRegions[i].cellZones()[iZone], iCell) //loop over all cells in Zone
{
cp=cp0_1+cp1_1*T+cp2_1*T*T;
K=K0_1+K1_1*T+K2_1*T*T;
rho=rho_1;
}
}
if (solidRegions[i].cellZones()[iZone].name() == "s-ic-ij") //with bla being name of porous cellZone
{
forAll(solidRegions[i].cellZones()[iZone], iCell) //loop over all cells in Zone
{
cp=cp0_1+cp1_1*T+cp2_1*T*T;
K=K0_1+K1_1*T+K2_1*T*T;
rho=rho_1;
}
}
if (solidRegions[i].cellZones()[iZone].name() == "s-ip") //with bla being name of porous cellZone
{
forAll(solidRegions[i].cellZones()[iZone], iCell) //loop over all cells in Zone
{
cp=cp0_1+cp1_1*T+cp2_1*T*T;
K=K0_1+K1_1*T+K2_1*T*T;
rho=rho_1;
}
}
}
/////////////////////////////////////
}
|
I derive the parameters by an aditional dict. The solver compiles without any probleme.
But when I start the simulation, it lasts very long to solve my solid region. I think the loops are responsible for that.
An additinal problem is that, that the values for cp, K and rho are not calculated different in the different zones.
Is there a mistake in my loops construction?
Is there a better alternative to calculate the properties different in different zones of the solid instead of my loops over all cells, which lasts so long?
Thanks in advance!
Best regards
Chrisi
|