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

Make a function available to a volSymmTensorField

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 26, 2020, 14:30
Default Make a function available to a volSymmTensorField
  #1
Member
 
Join Date: Feb 2020
Posts: 90
Rep Power: 6
Shibi is on a distinguished road
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





Shibi is offline   Reply With Quote

Old   November 27, 2020, 11:20
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,685
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
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.
olesen is offline   Reply With Quote

Reply

Tags
function, openfoam, programming


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
Two phase flow in porous medium Milaad OpenFOAM 6 December 15, 2020 07:55
[mesh manipulation] RefineMesh Error and Foam warning jiahui_93 OpenFOAM Meshing & Mesh Conversion 4 March 3, 2018 11:32
[swak4Foam] installation problem with version 0.2.3 Claudio87 OpenFOAM Community Contributions 9 May 8, 2013 10:20
is internalField(U) equivalent to zeroGradient? immortality OpenFOAM Running, Solving & CFD 7 March 29, 2013 01:27
Compilation errors in ThirdPartymallochoard feng_w OpenFOAM Installation 1 January 25, 2009 06:59


All times are GMT -4. The time now is 03:45.