jsagg |
August 10, 2016 12:42 |
Initialization of symmTensor by a coded function
Hi, I am trying to implement an utility that calculate time averages of different fields. So what I am doing is to compute the fields I need with a coded function in my ControlDict and after I use fieldAverage function Object.
By now, I am being inspired by this post where eelcovv and gschaider prupose different solutions for a similar issue.
My final goal is to be able to write volSymmTensorFields, volScalarFields and volVectorFields. However, I am not able to figure out the way to initialize volSymmTensorFields.
what I do to initialize a volScalarField is as follows:
Quote:
const volScalarField& TMod = mesh().lookupObject<volScalarField>("THigh");
const volScalarField& TModMean = mesh().lookupObject<volScalarField>("THighMean_w1" );
static autoPtr<volScalarField> TModpField;
if(!TModpField.valid())
{
Info << "Creating TModp" << nl;
TModpField.set
(
new volScalarField
(
IOobject
(
"TModp",
mesh().time().timeName(),
TMod.mesh(),
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
TMod-TModMean
)
);
}
volScalarField &TModp = TModpField();
TModp.checkIn();
TModp = TMod-TModMean;
Info << " TModp perturbated max " << max(TModp) << nl;
|
where TMod, TModMean and TModpField are the scalar fields. The trick here it is that I can initialize it directly by the expression TMod-TModMean.
Nevertheless, this is not the case for volsymmTensorFields.
So what I do so far for symmTensorFields is:
Quote:
if(!UpOUpField.valid())
{
Info << "Creating UpOUp" << nl;
UpOUpField.set
(
new volSymmTensorField
(
IOobject
(
"UpOUp",
mesh().time().timeName(),
U.mesh(),
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedSymmTensor
(
"UpOUp",
dimensionSet(0,2,-2,0,0,0,0),
symmTensor::zero
)
)
);
}
volSymmTensorField &UpOUp = UpOUpField();
UpOUp.checkIn();
forAll( Up.internalField(), i)
{
UpOUp.internalField()[i].component(symmTensor::XX) = Up.internalField()[i].component(vector::X)*Up.internalField()[i].component(vector::X);
UpOUp.internalField()[i].component(symmTensor::XY) = Up.internalField()[i].component(vector::X)*Up.internalField()[i].component(vector::Y);
UpOUp.internalField()[i].component(symmTensor::XZ) = Up.internalField()[i].component(vector::X)*Up.internalField()[i].component(vector::Z);
UpOUp.internalField()[i].component(symmTensor::YY) = Up.internalField()[i].component(vector::Y)*Up.internalField()[i].component(vector::Y);
UpOUp.internalField()[i].component(symmTensor::YZ) = Up.internalField()[i].component(vector::Y)*Up.internalField()[i].component(vector::Z);
UpOUp.internalField()[i].component(symmTensor::ZZ) = Up.internalField()[i].component(vector::Z)*Up.internalField()[i].component(vector::Z);
}
forAll( Up.boundaryField(), boundaryI)
{
forAll( Up.boundaryField()[boundaryI], i)
{
UpOUp.boundaryField()[boundaryI][i].component(symmTensor::XX) = Up.boundaryField()[boundaryI][i].component(vector::X)*Up.boundaryField()[boundaryI][i].component(vector::X);
UpOUp.boundaryField()[boundaryI][i].component(symmTensor::XY) = Up.boundaryField()[boundaryI][i].component(vector::X)*Up.boundaryField()[boundaryI][i].component(vector::Y);
UpOUp.boundaryField()[boundaryI][i].component(symmTensor::XZ) = Up.boundaryField()[boundaryI][i].component(vector::X)*Up.boundaryField()[boundaryI][i].component(vector::Z);
UpOUp.boundaryField()[boundaryI][i].component(symmTensor::YY) = Up.boundaryField()[boundaryI][i].component(vector::Y)*Up.boundaryField()[boundaryI][i].component(vector::Y);
UpOUp.boundaryField()[boundaryI][i].component(symmTensor::YZ) = Up.boundaryField()[boundaryI][i].component(vector::Y)*Up.boundaryField()[boundaryI][i].component(vector::Z);
UpOUp.boundaryField()[boundaryI][i].component(symmTensor::ZZ) = Up.boundaryField()[boundaryI][i].component(vector::Z)*Up.boundaryField()[boundaryI][i].component(vector::Z);
}
}
|
the issue it is that it seems that set member does not follows this syntax, since I get as error
Quote:
error: invalid use of non-static member function
|
to the line of
Quote:
dimensionSet(0,2,-2,0,0,0,0)
|
So summarizing does anybody knows how to initialize a symmTensor on the fly? As well, if anybody has a better idea to compute the fields an after feed fieldAverage is also welcome.
Thank you very much.
|