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

"Copy" element of a PtrList into another ListPtr

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 27, 2019, 08:35
Default "Copy" element of a PtrList into another ListPtr
  #1
Member
 
Fabien Robaux
Join Date: Oct 2016
Posts: 51
Rep Power: 9
frobaux is on a distinguished road
Hey,


I have results from another run that I want to import, (on a different dt as the current one)


I would like to keep a field with the previous values and one for the next value (to interpolate between both of them). For now I have something like

Code:
PtrList<pointScalarField> potPhiPrevious(externalPhiRegions.size());
PtrList<pointScalarField> potPhiNext(externalPhiRegions.size());
I set them reading files in 0/ and 0+outerDt/
Code:
forAll(externalPhiRegions, i)
{
 potPhiPrevious.set
    (
        i,
         new pointScalarField
       (
            IOobject
            (
                "Phi",
                pTime,
                externalPhiRegions[i],
                IOobject::MUST_READ,
                IOobject::NO_WRITE
            ),
            pMesh
        )
  );

 }
where pTime is of type word and stand for the previous time where this field is availae. And same for potPhiNext
The problem is at some times, I need to send

potPhiNext[i] into potPhiPrevious[i], and then read the new potPhiNext[i].



I've tried everything I could think of (
Code:
potPhiPrevious.set(i, potPhiNext[i]);
potPhiPrevious[i]=potPhiNext[i];
Always have an error at run that I dont understand...

Code:
#3  Foam::GeometricField<double, Foam::pointPatchField, Foam::pointMesh>::Boundary::Boundary(Foam::DimensionedField<double, Foam::pointMesh> const&, Foam::GeometricField<double, Foam::pointPatchField, Foam::pointMesh>::Boundary const&) at ??:?
#4  Foam::GeometricField<double, Foam::pointPatchField, Foam::pointMesh>::GeometricField(Foam::GeometricField<double, Foam::pointPatchField, Foam::pointMesh> const&) at ??:?
#5  Foam::GeometricField<double, Foam::pointPatchField, Foam::pointMesh>::clone() const at ??:?
#6  Foam::tmp<Foam::GeometricField<double, Foam::pointPatchField, Foam::pointMesh> >::ptr() const at ??:?
How could I do it properly, without re-reading the field or hard copying it.

Thanks a lot!

Last edited by frobaux; May 28, 2019 at 09:09.
frobaux is offline   Reply With Quote

Old   May 28, 2019, 09:32
Default
  #2
Member
 
Fabien Robaux
Join Date: Oct 2016
Posts: 51
Rep Power: 9
frobaux is on a distinguished road
After a entire day of following error, debugging and trying new stuffs, the only solution I came with was rereading it completely.



But the same problem appeared for the interpolated in time (I use a simple linear interpolation)


I set this one to be written at each time step:
Code:
    potPhi.set
    (
        i,
        new pointScalarField
        (
            IOobject
            (
                "Phi_interp",
                runTime.timeName(),
                externalPhiRegions[i],
                IOobject::NO_READ,
                IOobject::AUTO_WRITE
            ),
            potPhiPrevious[i]*(1-alph)+potPhiNext[i]*alph
        )
    );
But the neither runTime.write() nor potPhi[i].write() works, always the same memory problem.

Code:
#0  Foam::error::printStack(Foam::Ostream&) at ??:?
#1  Foam::sigSegv::sigHandler(int) at ??:?
#2  ? in "/lib/x86_64-linux-gnu/libc.so.6"
#3  ? in "/lib/x86_64-linux-gnu/libc.so.6"
Does anyone have an Idea?



Also, when I try to print potPhiPrevious[0].internalField() it always send an error like:

Code:
...
-2.24018e-09
-2.53537e-09
-2.85198e-09
)
;

    boundaryField
    {
#0  Foam::error::printStack(Foam::Ostream&) at ??:?
#1  Foam::sigSegv::sigHandler(int) at ??:?
#2  ? in "/lib/x86_64-linux-gnu/libc.so.6"
#3  Foam::GeometricField<double, Foam::pointPatchField, Foam::pointMesh>::Boundary::writeEntries(Foam::Ostream&) const at ~/These/OpenFOAM/v1712/OpenFOAM-v1712/src/OpenFOAM/lnInclude/GeometricBoundaryField.C:586
#4  Foam::GeometricField<double, Foam::pointPatchField, Foam::pointMesh>::Boundary::writeEntry(Foam::word const&, Foam::Ostream&) const at ~/These/OpenFOAM/v1712/OpenFOAM-v1712/src/OpenFOAM/lnInclude/GeometricBoundaryField.C:574 (discriminator 2)
#5  Foam::Ostream& Foam::operator<< <double, Foam::pointPatchField, Foam::pointMesh>(Foam::Ostream&, Foam::GeometricField<double, Foam::pointPatchField, Foam::pointMesh> const&) at ~/These/OpenFOAM/v1712/OpenFOAM-v1712/src/OpenFOAM/lnInclude/GeometricField.C:1337 (discriminator 2)
#6  Foam::GeometricField<double, Foam::pointPatchField, Foam::pointMesh>::writeData(Foam::Ostream&) const at ~/These/OpenFOAM/v1712/OpenFOAM-v1712/src/OpenFOAM/lnInclude/GeometricField.C:1036
#7  ? at ~/These/OpenFOAM/v1712/OpenFOAM-v1712/src/OpenFOAM/lnInclude/DimensionedFieldIO.C:151
#8  ? at ~/OpenFOAM/robaux-v1712/applications/solver/myCoupledHPCSolver/./externalPhi/createExternalPhiFields.H:115 (discriminator 7)
#9  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#10  ? at ??:?
If someone has any idea of where to look of understand this, I would be very grateful =)

Thanks a lot !
frobaux is offline   Reply With Quote

Old   June 4, 2019, 03:57
Default
  #3
Member
 
Fabien Robaux
Join Date: Oct 2016
Posts: 51
Rep Power: 9
frobaux is on a distinguished road
well, after a while and reading all treads containing PtrList and pointScalarField, I ended up finding the error, and it was my mistake..
The Sigrev error meant that there was empty memory somewhere and I tought it was due to the PtrList stuffs, but I was actually due to the fact that the pointMesh(es) associated with the pointScalarField(s) were not stored in memory.

I endend up adding a

PtrList<pointMesh> pMeshes(type1Regions.size())
frobaux is offline   Reply With Quote

Reply

Tags
copy, ptrlist, reference, regions


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
[Gmsh] 3D Mesh conversion from gmsh-2.5.0 to OpenFOAM Ancioi OpenFOAM Meshing & Mesh Conversion 17 January 8, 2019 23:50
Identifying Markers in a CGNS Mesh tjim SU2 3 October 12, 2018 01:21
[Other] Mesh Importing Problem cuteapathy ANSYS Meshing & Geometry 2 June 24, 2017 05:29
Temperature linearly rising after restarting a simulation Gennaro OpenFOAM Programming & Development 2 September 2, 2014 07:58
autoPatch error, mesh quality related...? Alexvader OpenFOAM 0 October 6, 2011 17:57


All times are GMT -4. The time now is 02:54.