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

Error calling calculated vector field as boundary condition in dynamic mesh

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 31, 2018, 18:01
Default Error calling calculated vector field as boundary condition in dynamic mesh
  #1
New Member
 
Paul Lee
Join Date: Jun 2018
Location: Vancouver
Posts: 14
Rep Power: 7
paoching is on a distinguished road
Hello everyone! I'm writing a custom solver for galvanic corrosion of metal based on the combination of electrostaticFoam and pimpleFoam. I'm calling it pimpleGalvanicFoam. Here is the solver, which I have no problem compiling.
https://1drv.ms/f/s!Auz_PRELFPQMg8N_VNv92oxsg4aePQ

My problem come when I try to modify /0/pointMotionU using #codestream.
I have calculated the volScalarField magCr for magnitude of corrosion rate in every time step, and I am trying to replace the standard uniform fixed value:
Code:
    anode
    {
        type            uniformFixedValue;
        uniformValue    uniform (0 0 -.5);
    }
with the calculated magCr by calling it from the object registry:
Code:
    anode
    {
        type            fixedValue;
        value           #codeStream
        {
          codeInclude
          #{
            #include "fvCFD.H"
          #};
          codeOptions
          #{
            -I$(LIB_SRC)/finiteVolume/lnInclude \
            -I$(LIB_SRC)/meshTools/lnInclude
          #};
          codeLibs
          #{
            -lmeshTools \
            -lfiniteVolume
          #};
          code
          #{
            const IOdictionary& d = static_cast<const IOdictionary&>
            (
              dict.parent().parent()
            );
            const fvMesh& mesh = refCast<const fvMesh>(d.db());
            const label id = mesh.boundary().findPatchID("anode");
            const fvPatch& patch = mesh.boundary()[id];
            const volScalarField& magCr = d.db().objectRegistry::lookupObject<volScalarField> ("magCr");
            const vectorField& Cf = patch.Cf();
            vectorField field(patch.size(), vector(0, 0, 0) );
            forAll(Cf, faceI)
            {
                field[faceI] = vector(0, 0, magCr[faceI]);
            }
          #};
        };
but I get the following error and I have no idea why and how to fix it. (I DO have magCr in my 0 directory)
Code:
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  6
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
Build  : 6-1a0c91b3baa8
Exec   : pimpleGalvanicFoam
Date   : Aug 31 2018
Time   : 14:54:27
Host   : "LAPTOP-QCU1KE67"
PID    : 26135
I/O    : uncollated
Case   : /mnt/c/Users/paoch/OneDrive/School/research/OpenFOAM/pimpleGalvanicTest
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster (fileModificationSkew 10)
allowSystemOperations : Allowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0

Selecting dynamicFvMesh dynamicMotionSolverFvMesh
Selecting motion solver: velocityLaplacian
Using #codeStream at line 31 in file "/mnt/c/Users/paoch/OneDrive/School/research/OpenFOAM/pimpleGalvanicTest/0/pointMotionU.boundaryField.anode"
Using #codeStream with "/mnt/c/Users/paoch/OneDrive/School/research/OpenFOAM/pimpleGalvanicTest/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libcodeStream_719c3cfd2ab59662a033822add60bfc90bd24489.so"


--> FOAM FATAL ERROR:

    request for volScalarField magCr from objectRegistry region0 failed
    available objects of type volScalarField are
0()

    From function const Type& Foam::objectRegistry::lookupObject(const Foam::word&) const [with Type = Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>]
    in file /home/ubuntu/OpenFOAM/OpenFOAM-6/src/OpenFOAM/lnInclude/objectRegistryTemplates.C at line 193.

FOAM aborting

#0  Foam::error::printStack(Foam::Ostream&) at ??:?
#1  Foam::error::abort() at ??:?
#2  Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const& Foam::objectRegistry::lookupObject<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >(Foam::word const&) const at ??:?
#3  codeStream_719c3cfd2ab59662a033822add60bfc90bd24489 at /usr/include/c++/7/bits/basic_string.h:211
#4  Foam::functionEntries::codeStream::execute(Foam::dictionary const&, Foam::primitiveEntry&, Foam::Istream&) at ??:?
#5  Foam::functionEntry::execute(Foam::word const&, Foam::dictionary const&, Foam::primitiveEntry&, Foam::Istream&) at ??:?
#6  Foam::primitiveEntry::expandFunction(Foam::word const&, Foam::dictionary const&, Foam::Istream&) at ??:?
#7  Foam::primitiveEntry::append(Foam::token const&, Foam::dictionary const&, Foam::Istream&) at ??:?
#8  Foam::primitiveEntry::read(Foam::dictionary const&, Foam::Istream&) at ??:?
#9  Foam::primitiveEntry::readEntry(Foam::dictionary const&, Foam::Istream&) at ??:?
#10  Foam::primitiveEntry::primitiveEntry(Foam::keyType const&, Foam::dictionary const&, Foam::Istream&) at ??:?
#11  Foam::entry::New(Foam::dictionary&, Foam::Istream&) at ??:?
#12  Foam::dictionary::read(Foam::Istream&, bool) at ??:?
#13  Foam::dictionary::dictionary(Foam::fileName const&, Foam::dictionary const&, Foam::Istream&) at ??:?
#14  Foam::dictionaryEntry::dictionaryEntry(Foam::keyType const&, Foam::dictionary const&, Foam::Istream&) at ??:?
#15  Foam::entry::New(Foam::dictionary&, Foam::Istream&) at ??:?
#16  Foam::dictionary::read(Foam::Istream&, bool) at ??:?
#17  Foam::dictionary::dictionary(Foam::fileName const&, Foam::dictionary const&, Foam::Istream&) at ??:?
#18  Foam::dictionaryEntry::dictionaryEntry(Foam::keyType const&, Foam::dictionary const&, Foam::Istream&) at ??:?
#19  Foam::entry::New(Foam::dictionary&, Foam::Istream&) at ??:?
#20  Foam::dictionary::read(Foam::Istream&, bool) at ??:?
#21  Foam::operator>>(Foam::Istream&, Foam::dictionary&) at ??:?
#22  Foam::baseIOdictionary::readData(Foam::Istream&) at ??:?
#23  Foam::fileOperations::uncollatedFileOperation::read(Foam::regIOobject&, bool, Foam::IOstream::streamFormat, Foam::word const&) const at ??:?
#24  Foam::regIOobject::readHeaderOk(Foam::IOstream::streamFormat, Foam::word const&) at ??:?
#25  Foam::localIOdictionary::localIOdictionary(Foam::IOobject const&, Foam::word const&) at ??:?
#26  Foam::GeometricField<Foam::Vector<double>, Foam::pointPatchField, Foam::pointMesh>::readFields() at ??:?
#27  Foam::GeometricField<Foam::Vector<double>, Foam::pointPatchField, Foam::pointMesh>::GeometricField(Foam::IOobject const&, Foam::pointMesh const&) at ??:?
#28  Foam::velocityMotionSolver::velocityMotionSolver(Foam::polyMesh const&, Foam::IOdictionary const&, Foam::word const&) at ??:?
#29  Foam::velocityLaplacianFvMotionSolver::velocityLaplacianFvMotionSolver(Foam::polyMesh const&, Foam::IOdictionary const&) at ??:?
#30  Foam::motionSolver::adddictionaryConstructorToTable<Foam::velocityLaplacianFvMotionSolver>::New(Foam::polyMesh const&, Foam::IOdictionary const&) at ??:?
#31  Foam::motionSolver::New(Foam::polyMesh const&, Foam::IOdictionary const&) at ??:?
#32  Foam::motionSolver::New(Foam::polyMesh const&) at ??:?
#33  Foam::dynamicMotionSolverFvMesh::dynamicMotionSolverFvMesh(Foam::IOobject const&) at ??:?
#34  Foam::dynamicFvMesh::addIOobjectConstructorToTable<Foam::dynamicMotionSolverFvMesh>::New(Foam::IOobject const&) at ??:?
#35  Foam::dynamicFvMesh::New(Foam::IOobject const&) at ??:?
#36  ? in "/home/paul/OpenFOAM/paul-6/platforms/linux64GccDPInt32Opt/bin/pimpleGalvanicFoam"
#37  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#38  ? in "/home/paul/OpenFOAM/paul-6/platforms/linux64GccDPInt32Opt/bin/pimpleGalvanicFoam"
Aborted (core dumped)
Any Insight/idea/critique/solution is appreciated.
and here is my case file:
https://1drv.ms/f/s!Auz_PRELFPQMg8UEhBbeGzIh57-NOg
paoching is offline   Reply With Quote

Reply

Tags
codestream, dynamic mesh, electrostaticfoam, galvanic, pimplefoam


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
sliding mesh problem in CFX Saima CFX 46 September 11, 2021 07:38
Centrifugal fan j0hnny CFX 13 October 1, 2019 13:55
Error - Solar absorber - Solar Thermal Radiation MichaelK CFX 12 September 1, 2016 05:15
Radiation interface hinca CFX 15 January 26, 2014 17:11
Question about heat transfer coefficient setting for CFX Anna Tian CFX 1 June 16, 2013 06:28


All times are GMT -4. The time now is 08:05.