CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   recompiling moveEngineMesh (http://www.cfd-online.com/Forums/openfoam-programming-development/117789-recompiling-moveenginemesh.html)

fogl May 15, 2013 05:21

recompiling moveEngineMesh
 
I would like to recompile the moveEngineMesh solver/utility. I made a copy and changed its name (to moveEngineMeshKD1), recompile and run. Everything went smooth. Then i also made a copy of engineMesh.H/C and changed its name to engineMeshKD1.H/C.

Then i did a small modification of my copy of engineMeshKD1.H/C - i changed the names of boundaries (pistonHead, linear and piston). I modified the #include line in the top of moveEngineMeshKD1.c to include the new modified file. I added the file path to options. I recompiled and then run. The new solver/utility showed an error:

--> FOAM FATAL ERROR:
cannot find piston patch
From function engineMesh::engineMesh(const IOobject& io)
in file engineMesh/engineMesh/engineMesh.C at line 79.
FOAM exiting


It seems my modified engineMeshKD1 was not included. I have no idea why is that. I did not include the engineMesh.h, i changed it to engineMeshKD1.h. Any idea what am i doing wrong? I attached the code changes below.

Regards,
Klemen


------------------ wmake ------------------
Making dependency list for source file moveEngineMeshKD1.C
SOURCE=moveEngineMeshKD1.C ; g++ -m32 -Dlinux -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-100 -I/opt/openfoam220/src/finiteVolume/lnInclude -I/opt/openfoam220/src/engine/lnInclude -I/home/klemen/OpenFOAM/klemen-2.2.0/applications/utilities/engineMeshKD1 -IlnInclude -I. -I/opt/openfoam220/src/OpenFOAM/lnInclude -I/opt/openfoam220/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linuxGccDPOpt/moveEngineMeshKD1.o
g++ -m32 -Dlinux -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-100 -I/opt/openfoam220/src/finiteVolume/lnInclude -I/opt/openfoam220/src/engine/lnInclude -I/home/klemen/OpenFOAM/klemen-2.2.0/applications/utilities/engineMeshKD1 -IlnInclude -I. -I/opt/openfoam220/src/OpenFOAM/lnInclude -I/opt/openfoam220/src/OSspecific/POSIX/lnInclude -fPIC -Xlinker --add-needed -Xlinker --no-as-needed Make/linuxGccDPOpt/moveEngineMeshKD1.o -L/opt/openfoam220/platforms/linuxGccDPOpt/lib \
-lfiniteVolume -lengine -ldynamicMesh -lOpenFOAM -ldl -lm -o /home/klemen/OpenFOAM/klemen-2.2.0/platforms/linuxGccDPOpt/bin/moveEngineMeshKD1
klemen@klemen-VirtualBox:~/OpenFOAM/klemen-2.2.0/applications/utilities/moveEngineMeshKD1$

------------------ moveEngineMeshKD1 ------------------
#include "fvCFD.H"
#include "engineTime.H"
#include "engineMeshKD1.H" // CHANGE

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

int main(int argc, char *argv[])
{
# include "setRootCase.H"

# include "createEngineTime.H"
# include "createEngineMesh.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

Info<< "\nStarting time loop\n" << endl;

while (runTime.loop())
{
Info<< "Time = " << runTime.theta() << " CA-deg\n" << endl;

mesh.move();

runTime.write();

Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}

Info<< "End\n" << endl;

return 0;
}


------------------ engineMeshKD1.c ------------------
#include "engineMeshKD1.H"
#include "dimensionedScalar.H"

// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

namespace Foam
{
defineTypeNameAndDebug(engineMesh, 0);
defineRunTimeSelectionTable(engineMesh, IOobject);
}


// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //

Foam::engineMesh::engineMesh(const IOobject& io)
:
fvMesh(io),
engineDB_(refCast<const engineTime>(time())),
pistonIndex_(-1),
linerIndex_(-1),
cylinderHeadIndex_(-1),
deckHeight_("deckHeight", dimLength, GREAT),
pistonPosition_("pistonPosition", dimLength, -GREAT)
{
bool foundPiston = false;
bool foundLiner = false;
bool foundCylinderHead = false;

forAll(boundary(), i)
{
if (boundary()[i].name() == "compPistonHead") // CHANGE
{
pistonIndex_ = i;
foundPiston = true;
}
else if (boundary()[i].name() == "compLiner") // CHANGE
{
linerIndex_ = i;
foundLiner = true;
}
else if (boundary()[i].name() == "compCylinderHead") // CHANGE
{
cylinderHeadIndex_ = i;
foundCylinderHead = true;
}
}

reduce(foundPiston, orOp<bool>());
reduce(foundLiner, orOp<bool>());
reduce(foundCylinderHead, orOp<bool>());

if (!foundPiston)
{
FatalErrorIn("KD: engineMesh::engineMesh(const IOobject& io)")
<< "KD cannot find patch"
<< exit(FatalError);
}

if (!foundLiner)
{
FatalErrorIn("KD: engineMesh::engineMesh(const IOobject& io)")
<< "KD cannot find patch"
<< exit(FatalError);
}

if (!foundCylinderHead)
{
FatalErrorIn("KD: engineMesh::engineMesh(const IOobject& io)")
<< "KD cannot find patch"
<< exit(FatalError);
}

{
if (pistonIndex_ != -1)
{
pistonPosition_.value() = -GREAT;
if (boundary()[pistonIndex_].patch().localPoints().size())
{
pistonPosition_.value() =
max(boundary()[pistonIndex_].patch().localPoints()).z();
}
}
reduce(pistonPosition_.value(), maxOp<scalar>());

if (cylinderHeadIndex_ != -1)
{
deckHeight_.value() = GREAT;
if (boundary()[cylinderHeadIndex_].patch().localPoints().size())
{
deckHeight_.value() = min
(
boundary()[cylinderHeadIndex_].patch().localPoints()
).z();
}
}
reduce(deckHeight_.value(), minOp<scalar>());

Info<< "deckHeight: " << deckHeight_.value() << nl
<< "piston position: " << pistonPosition_.value() << endl;
}
}


// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

Foam::engineMesh::~engineMesh()
{}


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