This repository has been archived on 2023-11-20. You can view files and clone it, but cannot push or open issues or pull requests.
foam-extend4.1-coherent-io/applications/solvers/equationReader/equationReaderDemo/initializeSourceFields.H
2013-08-29 15:03:52 -05:00

191 lines
5.2 KiB
C

// Initializing the scalarFields
forAll(sfA, cellIndex)
{
scalar cellValue(scalar(cellIndex) / 100000);
sfA[cellIndex] = 10 + cellValue;
sfB[cellIndex] = 20 + cellValue;
sfC[cellIndex] = 30 + cellValue;
}
// Initializing the volScalarFields
label globalI(0);
forAll(vsfA.internalField(), cellIndex)
{
scalar cellValue(scalar(globalI) / 100000);
vsfA.internalField()[cellIndex] = 40 + cellValue;
vsfB.internalField()[cellIndex] = 50 + cellValue;
vsfC.internalField()[cellIndex] = 60 + cellValue;
globalI++;
}
forAll(vsfA.boundaryField(), geoIndex)
{
forAll(vsfA.boundaryField()[geoIndex], cellIndex)
{
scalar cellValue(scalar(globalI) / 100000);
vsfA.boundaryField()[geoIndex][cellIndex] = 40 + cellValue;
vsfB.boundaryField()[geoIndex][cellIndex] = 50 + cellValue;
vsfC.boundaryField()[geoIndex][cellIndex] = 60 + cellValue;
globalI++;
}
}
// Initializing the vectorFields
forAll(vfA, cellIndex)
{
scalar cellValue(scalar(cellIndex) / 100000);
vfA[cellIndex] = vector
(
1000 + cellValue,
1000 + cellValue,
1000 + cellValue
);
vfB[cellIndex] = vector
(
2000 + cellValue,
-2000 - cellValue,
2000 + cellValue
);
vfC[cellIndex] = vector
(
3000 + cellValue,
3000 + cellValue,
-3000 - cellValue
);
}
// Initializing the volVectorFields
globalI = 0;
forAll(vvfA.internalField(), cellIndex)
{
scalar cellValue(scalar(globalI) / 100000);
vvfA.internalField()[cellIndex] = vector
(
4000 + cellValue,
4000 + cellValue,
4000 + cellValue
);
vvfB.internalField()[cellIndex] = vector
(
5000 + cellValue,
-5000 - cellValue,
5000 + cellValue
);
vvfC.internalField()[cellIndex] = vector
(
6000 + cellValue,
6000 + cellValue,
-6000 - cellValue
);
globalI++;
}
forAll(vvfA.boundaryField(), geoIndex)
{
forAll(vvfA.boundaryField()[geoIndex], cellIndex)
{
scalar cellValue(scalar(globalI) / 100000);
vvfA.boundaryField()[geoIndex][cellIndex] = vector
(
4000 + cellValue,
4000 + cellValue,
4000 + cellValue
);
vvfB.boundaryField()[geoIndex][cellIndex] = vector
(
5000 + cellValue,
-5000 - cellValue,
5000 + cellValue
);
vvfC.boundaryField()[geoIndex][cellIndex] = vector
(
6000 + cellValue,
6000 + cellValue,
-6000 - cellValue
);
globalI++;
}
}
// Initializing the tensorFields
forAll(tfA, cellIndex)
{
scalar cellValue(scalar(cellIndex) / 100000);
scalar tA(cellValue + 100000);
scalar tB(cellValue + 200000);
scalar tC(cellValue + 300000);
tfA[cellIndex] = tensor
(
tA, -tA, tA,
-tA, tA, -tA,
tA, -tA, tA
);
tfB[cellIndex] = tensor
(
tB, tB, -tB,
tB, -tB, tB,
-tB, tB, -tB
);
tfC[cellIndex] = tensor
(
tC, tC, -tC,
-tC, tC, tC,
-tC, -tC, tC
);
}
// Initializing the volTectorFields
globalI = 0;
forAll(vtfA.internalField(), cellIndex)
{
scalar cellValue(scalar(globalI) / 100000);
scalar tA(cellValue + 400000);
scalar tB(cellValue + 500000);
scalar tC(cellValue + 600000);
vtfA.internalField()[cellIndex] = tensor
(
tA, -tA, tA,
-tA, tA, -tA,
tA, -tA, tA
);
vtfB.internalField()[cellIndex] = tensor
(
tB, tB, -tB,
tB, -tB, tB,
-tB, tB, -tB
);
vtfC.internalField()[cellIndex] = tensor
(
tC, tC, -tC,
-tC, tC, tC,
-tC, -tC, tC
);
globalI++;
}
forAll(vtfA.boundaryField(), geoIndex)
{
forAll(vtfA.boundaryField()[geoIndex], cellIndex)
{
scalar cellValue(scalar(globalI) / 100000);
scalar tA(cellValue + 400000);
scalar tB(cellValue + 500000);
scalar tC(cellValue + 600000);
vtfA.boundaryField()[geoIndex][cellIndex] = tensor
(
tA, -tA, tA,
-tA, tA, -tA,
tA, -tA, tA
);
vtfB.boundaryField()[geoIndex][cellIndex] = tensor
(
tB, tB, -tB,
tB, -tB, tB,
-tB, tB, -tB
);
vtfC.boundaryField()[geoIndex][cellIndex] = tensor
(
tC, tC, -tC,
-tC, tC, tC,
-tC, -tC, tC
);
globalI++;
}
}