|
[Sponsors] |
January 19, 2010, 17:27 |
const_cast and pointScalarField
|
#1 |
New Member
Michael G.
Join Date: Sep 2009
Location: Germany, Nds.
Posts: 13
Rep Power: 17 |
Hello OpenFoam-Users,
I got a problem with compiling a modified interDyMFoam-solver. My goal is to modify the mesh motion every n-th timestep and I found out that this can be done by a const_cast: Code:
pointScalarField& field = const_cast<pointScalarField&> ( mesh.objectRegistry::lookupObject<pointScalarField> ( "pointDisplacementz" ) ); Code:
[...] /home/michael/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/DimensionedField.H: At global scope: /home/michael/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/DimensionedField.H: In instantiation of ‘Foam::DimensionedField<double, Foam::pointMesh>’: /home/michael/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/pointFieldsFwd.H:53: instantiated from ‘Foam::GeometricField<double, Foam::pointPatchField, Foam::pointMesh>’ /home/michael/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/objectRegistryTemplates.C:114: instantiated from ‘const Type& Foam::objectRegistry::lookupObject(const Foam::word&) const [with Type = Foam::GeometricField<double, Foam::pointPatchField, Foam::pointMesh>]’ interDyMFoam.C:66: instantiated from here /home/michael/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/DimensionedField.H:83: error: invalid use of incomplete type ‘struct Foam::pointMesh’ /home/michael/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/pointFieldsFwd.H:47: error: forward declaration of ‘struct Foam::pointMesh’ /home/michael/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/DimensionedField.H:92: error: invalid use of incomplete type ‘struct Foam::pointMesh’ /home/michael/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/pointFieldsFwd.H:47: error: forward declaration of ‘struct Foam::pointMesh’ /home/michael/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/DimensionedField.C:58: error: invalid use of incomplete type ‘struct Foam::pointMesh’ /home/michael/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/pointFieldsFwd.H:47: error: forward declaration of ‘struct Foam::pointMesh’ [Similar error messages follow] Anyone knows the reason or has a hint? Thank you for reading this and, of course, for your answers. |
|
January 20, 2010, 06:53 |
|
#2 |
Senior Member
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,907
Rep Power: 33 |
Go to the file you are compiling and add
#include "pointMesh.H" at the top. Hrv
__________________
Hrvoje Jasak Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk |
|
January 21, 2010, 11:56 |
|
#3 |
New Member
Michael G.
Join Date: Sep 2009
Location: Germany, Nds.
Posts: 13
Rep Power: 17 |
HeyHey Hrv,
thanks alot for that hint! I would have never thought of that (C++ skills not present ;D). So, much thanks to you and a C++-lesson to me! For all OF-users finding this thread in the future: You have to add #include "pointMesh.H" #include "pointPatchField.H" at the top(!) of your file The cast for editing mesh-movement may look like: (For motion-solver displacementLaplacian) Info << "Reading field pointDisplacement" << endl; pointVectorField& pointDisplacement = const_cast<pointVerctorField&> ( mesh.objectRegistry::lookupObject<pointVectorField > ( "pointDisplacement" ) ); [and again for cellDisplacement] Writing new values on boundary: label patchIndex = mesh.boundaryMesh().findPatchID("patch_name"); cellDisplacement.boundaryField()[patchIndex] = newvalue; pointDisplacement.boundaryField()[patchIndex] = newvalue; |
|
April 26, 2016, 12:02 |
|
#4 |
New Member
Join Date: Mar 2014
Posts: 9
Rep Power: 12 |
Greetings from the future! Thank you, this was very useful!
Best, N |
|
|
|