|
[Sponsors] | |||||
Make a function available to a volSymmTensorField |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|
|
#1 |
|
Member
Join Date: Feb 2020
Posts: 90
Rep Power: 7 ![]() |
Hello to all,
I'm new to programming in OpenFoam and would like to know the following: I defined a custom function in OpenFoam that takes as input two tensors and returns a symmetric tensor. Code:
inline SymmTensor<scalar> test(const Tensor<scalar>& a, const Tensor<scalar>& b)
{
SymmTensor<scalar> tmp(symm(a+b));
return tmp;
}
I would like to be able to initialize a volSymmTensorField with this function, taking as input two volTensorFields .e.g, Code:
volTensorField a
(
IOobject
(
"a",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
Tensor<scalar>::I
);
volTensorField b
(
IOobject
(
"b",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
Tensor<scalar>::I
);
volSymmTensorField test
(
IOobject
(
"test",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
test(a,b)
);
Is this possible? What steps do I need to take to make this work? Best Regards! Is |
|
|
|
|
|
|
|
|
#2 |
|
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 41 ![]() ![]() |
Sure it is possible, but is a bit of work. Starting from the bottom and working our way up.
- define function operating on two tensors - define function for plain lists/fields - see FieldFunctions.H - define function for a field of fields - see FieldFieldFunctions.H - define function for dimensioned (internal) fields - see DimensionedFieldFunctions.H - finally define function for volume fields, handling internal and boundary (FieldFields) - see GeometricFieldFunctions.H A bit of work, but certainly a really good way to learn. |
|
|
|
|
|
![]() |
| Tags |
| function, openfoam, programming |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Two phase flow in porous medium | Milaad | OpenFOAM | 7 | July 1, 2024 06:08 |
| [mesh manipulation] RefineMesh Error and Foam warning | jiahui_93 | OpenFOAM Meshing & Mesh Conversion | 4 | March 3, 2018 12:32 |
| [swak4Foam] installation problem with version 0.2.3 | Claudio87 | OpenFOAM Community Contributions | 9 | May 8, 2013 11:20 |
| is internalField(U) equivalent to zeroGradient? | immortality | OpenFOAM Running, Solving & CFD | 7 | March 29, 2013 02:27 |
| Compilation errors in ThirdPartymallochoard | feng_w | OpenFOAM Installation | 1 | January 25, 2009 07:59 |