|
[Sponsors] |
November 15, 2019, 10:34 |
autoPtr doesn't create a "new"
|
#1 |
Member
Fabien Robaux
Join Date: Oct 2016
Posts: 51
Rep Power: 10 |
Hello everyone,
I've a noticed a strange behavior in my code, I'm sure it is my mistake or my lack of understanding but I could understand it: I have a field that I want to interpolate. I've coded something like Code:
autoPtr<interpolation<vector>> interpV ( interpolation<vector>::New(mapMethod2, srcV) ); forAll(tgtMesh.C(), tgtCelli) { const point & p=tgtMesh.C()[tgtCelli]; const label & srcCelli= srcMesh.findCell(p); VfromExternal[tgtCelli]= interpV().interpolate(p, srcCelli, -1); } Code:
return autoPtr<interpolation<Type>>(cstrIter()(psi)); Code:
template<class Type> Foam::interpolationCellPoint<Type>::interpolationCellPoint ( const GeometricField<Type, fvPatchField, volMesh>& psi ) : interpolation<Type>(psi), psip_ ( volPointInterpolation::New(psi.mesh()).interpolate ( psi, "volPointInterpolate(" + psi.name() + ')', true // use cache ) ) { psip_.write(); // local modif Info << "should write pointField" << psip_.name() << endl; //local modif // Uses cellPointWeight to do interpolation which needs tet decomposition (void)psi.mesh().tetBasePtIs(); } My guess is the new srcV is so close (~10^-3) from the previous one that autoPtr does not actually recompute the volPointInterpolation needed : psip_ is not recomputed inside interpolationCellPoint.H. The problem is I need to and the final results are really sensitive to that! should I manually destroy the interpV at the end? (and how do I do that?) Am I doing something wrong? Edit: The same behavior is obtained when I tried to define interpV as a const reference of directly interpolationCellPoint Code:
const interpolationCellPoint<vector> & interpV (srcV); Thanks a lot for your inputs! Sincerely, Fabien Last edited by frobaux; November 15, 2019 at 13:23. |
|
November 18, 2019, 05:14 |
|
#2 |
Member
Fabien Robaux
Join Date: Oct 2016
Posts: 51
Rep Power: 10 |
Well, after a lot of print and research everywhere, I've found the culprit!!!
The problem was in Code:
psip_ ( volPointInterpolation::New(psi.mesh()).interpolate ( psi, "volPointInterpolate(" + psi.name() + ')', true // use cache // THIS IS THE CULPRIT ) ) Now, I do it manually Code:
sourceV.evenNo()=sourceV.eventNo()+1 // this is wrong, see edits EDIT: I was wrong, it does not run well. I forgot to recompile the "true".. Inside the volPointInterpolation::New(psi.mesh()).interpolate the eventNo is way to important. +1 does not help matching it... EDIT2: Well I was an idiot, I found out that -If this time I'm right- the eventNo is more of a global number counting all occurence. To set a n object as updated, used myObject.setUpToDate() instead (it sets myObject.eventNo_= db().getEvent() ) Last edited by frobaux; November 18, 2019 at 12:32. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
create the file *.foam | phongstar | OpenFOAM | 12 | October 14, 2018 19:06 |
[GAMBIT] How to plot S pipe | mariam.sara | ANSYS Meshing & Geometry | 36 | November 7, 2013 16:22 |
[ANSYS Meshing] is it possible to create virtual edges on the blades | er_ijaz | ANSYS Meshing & Geometry | 0 | November 3, 2013 06:15 |
[DesignModeler] Design Modeller create surface | papis | ANSYS Meshing & Geometry | 0 | October 31, 2013 14:52 |
About create interface! | xinzhiyu2008 | STAR-CCM+ | 2 | August 6, 2010 21:47 |