CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Post-Processing

How to access mesh/objectRegistry via codeStream in a sampleDict (v1912)?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 1, 2021, 07:48
Default How to access mesh/objectRegistry via codeStream in a sampleDict (v1912)?
  #1
New Member
 
Join Date: Jun 2021
Posts: 1
Rep Power: 0
CFDMojo is on a distinguished road
Hello everyone,


in order to analyse boundary layer profiles on an airfoil I need to sample surface normal lines. For this purpose I tried to use codeStream in my sampleDict to automatically set the start and end points of the lines. Therefore, I need the surface normals from the mesh.



My first approach to access the mesh, was the following:
Code:
wallNormalEndPoint #codeStream
{
    code
    #{
        const IOdictionary& d = static_cast<const IOdictionary&>(dict);
        const fvMesh& mesh = refCast<const fvMesh>(d.db());


        vector nearestP1(0, 0, 0); // only for testing
        vector normal(-1, 0, 0);    // only for testing
        vector endPoint;
        endPoint = nearestP1 + normal;
         Info << "P1 = (" << endPoint.x() << " " <<  endPoint.y() << " " << endPoint.z() << ")" <<  endl;
        os << "(" << endPoint.x() << " "  << endPoint.y() << " " << endPoint.z() << ")";
    #};

    //! Optional:
    codeInclude
    #{
        #include "fvCFD.H"
        #include "fvMesh.H"
    #};

    //! Optional:
    codeOptions
    #{
        -I$(LIB_SRC)/finiteVolume/lnInclude \
        -I$(LIB_SRC)/meshTools/lnInclude \
        -I$(LIB_SRC)/OpenFOAM/lnInclude/
    #};
    //! libs:
    codeLibs
    #{
        -lmeshTools \
        -lfiniteVolume
    #};
};
This seems to be the way, how to access the mesh via codeStream in preProcessing dictionaries like blockMeshDict or boundary. Unfortunately this is not working in my case. When running

Code:
pimpleFoam -postProcess -latestTime -func sample
I get a segmentation fault error:


Code:
Using #codeStream at line 32 in file ".../system/sample"
Using  #codeStream with  ".../dynamicCode/platforms/linux64Gcc7DPInt32Opt/lib/libcodeStream_ab16c0dcca50c69f8e3bea68d47adc1f7bc2dd69.so"
P1 = (0 0 0)
Using #codeStream at line 99 in file ".../system/sample"
Using  #codeStream with  ".../dynamicCode/platforms/linux64Gcc7DPInt32Opt/lib/libcodeStream_51d2e298681900269ae92473d9c4ffb099161003.so"
Creating  new library in  "dynamicCode/_51d2e298681900269ae92473d9c4ffb099161003/platforms/linux64Gcc7DPInt32Opt/lib/libcodeStream_51d2e298681900269ae92473d9c4ffb099161003.so"
Invoking wmake libso .../dynamicCode/_51d2e298681900269ae92473d9c4ffb099161003
wmake libso .../dynamicCode/_51d2e298681900269ae92473d9c4ffb099161003
    ln: ./lnInclude
    dep: codeStreamTemplate.C
    Ctoo: codeStreamTemplate.C
codeStreamTemplate.C:  In function ‘void  Foam::codeStream_51d2e298681900269ae92473d9c4ffb099161003(Foam::Ostream&,  const Foam::dictionary&)’:
codeStreamTemplate.C:60:23: warning: unused variable ‘mesh’ [-Wunused-variable]
         const fvMesh& mesh = refCast<const fvMesh>(d.db());
                       ^~~~
     ld:  .../dynamicCode/_51d2e298681900269ae92473d9c4ffb099161003/../platforms/linux64Gcc7DPInt32Opt/lib/libcodeStream_51d2e298681900269ae92473d9c4ffb099161003.so
#0  Foam::error::printStack(Foam::Ostream&) at ??:?
#1  Foam::sigSegv::sigHandler(int) at ??:?
#2  ? in /lib64/libc.so.6
#3  __dynamic_cast in /usr/lib64/libstdc++.so.6
#4   Foam::fvMesh const& Foam::refCast<Foam::fvMesh const,  Foam::objectRegistry const>(Foam::objectRegistry const&) at ??:?
#5   codeStream_51d2e298681900269ae92473d9c4ffb099161003addr2line: DWARF  error: could not find variable specification at offset 2660
addr2line: DWARF error: could not find variable specification at offset 26b9
addr2line: DWARF error: could not find variable specification at offset 271d
addr2line: DWARF error: could not find variable specification at offset ac91
addr2line: DWARF error: could not find variable specification at offset ac9c
addr2line: DWARF error: could not find variable specification at offset b2c0
addr2line: DWARF error: could not find variable specification at offset b302
addr2line: DWARF error: could not find variable specification at offset b344
addr2line: DWARF error: could not find variable specification at offset b386
addr2line: DWARF error: could not find variable specification at offset b3b2
addr2line: DWARF error: could not find variable specification at offset b3e9
addr2line: DWARF error: could not find variable specification at offset b3f4
addr2line: DWARF error: could not find variable specification at offset b42b
addr2line: DWARF error: could not find variable specification at offset b436
addr2line: DWARF error: could not find variable specification at offset 1cc1
addr2line: DWARF error: could not find variable specification at offset 1cf5
addr2line: DWARF error: could not find variable specification at offset 1d0f
addr2line: DWARF error: could not find variable specification at offset 7764
addr2line: DWARF error: could not find variable specification at offset 90cd
addr2line: DWARF error: could not find variable specification at offset 90e3
addr2line: DWARF error: could not find variable specification at offset 900c
addr2line: DWARF error: could not find variable specification at offset 906c
addr2line: DWARF error: could not find variable specification at offset 912b
addr2line: DWARF error: could not find variable specification at offset 9141
addr2line: DWARF error: could not find variable specification at offset 9189
addr2line: DWARF error: could not find variable specification at offset 919f
addr2line: DWARF error: could not find variable specification at offset 9205
addr2line: DWARF error: could not find variable specification at offset aa58
 at dynamicCode/_51d2e298681900269ae92473d9c4ffb099161003/codeStreamTemplate.C:60
#6  Foam::functionEntries::codeStream::evaluate(Foam::dictionary const&, Foam::Istream&) at ??:?
#7   Foam::functionEntries::codeStream::execute(Foam::dictionary const&,  Foam::primitiveEntry&, Foam::Istream&) at ??:?
#8   Foam::functionEntry::execute(Foam::word const&, Foam::dictionary  const&, Foam::primitiveEntry&, Foam::Istream&) at ??:?
#9  Foam::primitiveEntry::acceptToken(Foam::token const&, Foam::dictionary const&, Foam::Istream&) at ??:?
#10  Foam::primitiveEntry::read(Foam::dictionary const&, Foam::Istream&) at ??:?
#11  Foam::primitiveEntry::readEntry(Foam::dictionary const&, Foam::Istream&) at ??:?
#12  Foam::primitiveEntry::primitiveEntry(Foam::keyType const&, Foam::dictionary const&, Foam::Istream&) at ??:?
#13  Foam::entry::New(Foam::dictionary&, Foam::Istream&, Foam::entry::inputMode, int) at ??:?
#14  Foam::dictionary::read(Foam::Istream&, bool) at ??:?
#15  Foam::dictionary::dictionary(Foam::Istream&, bool) at ??:?
#16   Foam::functionObjectList::readFunctionObject(Foam::string const&,  Foam::dictionary&, Foam::HashSet<Foam::wordRe,  Foam::string::hash>&, Foam::word const&) at ??:?
#17   Foam::functionObjectList::New(Foam::argList const&, Foam::Time  const&, Foam::dictionary&, Foam::HashSet<Foam::wordRe,  Foam::string::hash>&) at ??:?
#18  ? at ??:?
#19  __libc_start_main in /lib64/libc.so.6
#20  ? at /home/abuild/rpmbuild/BUILD/glibc-2.26/csu/../sysdeps/x86_64/start.S:122
I also tried to get other information from the objectRegistry, like d.db().time().value();, which results in the same error.
For me it seems like I have no access to the objectRegistry when I use codeStream in a sampleDict. :/



Am I doing something wrong or is it just not possible to access the mesh?


Thanks in advance for any help or ideas.
CFDMojo is offline   Reply With Quote

Reply

Tags
codestream, mesh, objectregistry, post-processing, sampledict


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
Access cell values in codeStream gomz OpenFOAM Programming & Development 2 April 27, 2022 05:30
different results form openfoam 3.0.1 to 1912 yuno OpenFOAM Running, Solving & CFD 0 September 28, 2020 04:09
PROBLEMS DEFINING A LIST USING #CODESTREAM !! Help please !! angatri_14 OpenFOAM Programming & Development 1 August 21, 2020 18:16
Is there a way to access the gradient limiter in Fluent ? CFDYourself FLUENT 1 February 16, 2016 06:49
controlDict and sampleDict giving different results Shenan OpenFOAM Post-Processing 2 November 15, 2014 11:15


All times are GMT -4. The time now is 22:23.