CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Initialization of symmTensor by a coded function

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 2 Post By Tobi
  • 1 Post By Tobi

 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old   August 10, 2016, 12:42
Default Initialization of symmTensor by a coded function
  #1
New Member
 
Javier Sierra Ausin
Join Date: Jul 2016
Location: Toulouse
Posts: 1
Rep Power: 0
jsagg is on a distinguished road
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.
jsagg is offline   Reply With Quote

 

Tags
controldict, fieldaverage, function, initialization, tensor


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[blockMesh] edges not aligned with or perpendicular to non-empty directions ynos OpenFOAM Meshing & Mesh Conversion 6 March 26, 2020 15:02
Question about Initialization of Signed Distance Function (LEVEL SET) jl21_87 Main CFD Forum 0 January 10, 2012 21:50
channelFoam for a 3D pipe AlmostSurelyRob OpenFOAM 3 June 24, 2011 13:06
Compilation errors in ThirdPartymallochoard feng_w OpenFOAM Installation 1 January 25, 2009 06:59
Problem with compile the setParabolicInlet ivanyao OpenFOAM Running, Solving & CFD 6 September 5, 2008 20:50


All times are GMT -4. The time now is 15:04.