Corrected multiRegionHeater tutorial.

This commit is contained in:
henry
2010-04-29 14:21:11 +01:00
11 changed files with 108 additions and 40 deletions

View File

@ -60,7 +60,7 @@ class magnet
// Private data // Private data
word name_; word name_;
scalar relativPermeability_; scalar relativePermeability_;
dimensionedScalar remanence_; dimensionedScalar remanence_;
vector orientation_; vector orientation_;
@ -85,7 +85,7 @@ public:
) )
: :
name_(name), name_(name),
relativPermeability_(mur), relativePermeability_(mur),
remanence_("Mr", dimensionSet(0, -1, 0, 0, 0, 1, 0), Mr), remanence_("Mr", dimensionSet(0, -1, 0, 0, 0, 1, 0), Mr),
orientation_(orientation) orientation_(orientation)
{} {}
@ -111,7 +111,7 @@ public:
//- Return relative permeability //- Return relative permeability
inline scalar mur() const inline scalar mur() const
{ {
return relativPermeability_; return relativePermeability_;
} }
//- Return remenance //- Return remenance
@ -133,7 +133,7 @@ public:
{ {
is.readBegin("magnet"); is.readBegin("magnet");
is >> m.name_ is >> m.name_
>> m.relativPermeability_ >> m.relativePermeability_
>> m.remanence_.value() >> m.remanence_.value()
>> m.orientation_; >> m.orientation_;
is.readEnd("magnet"); is.readEnd("magnet");
@ -148,7 +148,7 @@ public:
{ {
os << token::BEGIN_LIST os << token::BEGIN_LIST
<< m.name_ << token::SPACE << m.name_ << token::SPACE
<< m.relativPermeability_ << token::SPACE << m.relativePermeability_ << token::SPACE
<< m.remanence_.value() << m.remanence_.value()
<< m.orientation_ << m.orientation_
<< token::END_LIST; << token::END_LIST;

View File

@ -29,7 +29,8 @@ Description
A Poisson's equation for the magnetic scalar potential psi is solved A Poisson's equation for the magnetic scalar potential psi is solved
from which the magnetic field intensity H and magnetic flux density B from which the magnetic field intensity H and magnetic flux density B
are obtained. are obtained. The paramagnetic particle force field (H dot grad(H))
is optionally available.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -42,8 +43,23 @@ Description
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::addBoolOption("noH", "do not write the magnetic field"); argList::addBoolOption
argList::addBoolOption("noB", "do not write the magnetic field"); (
"noH",
"do not write the magnetic field intensity field"
);
argList::addBoolOption
(
"noB",
"do not write the magnetic flux density field"
);
argList::addBoolOption
(
"HdotGradH",
"write the paramagnetic particle force field"
);
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"
@ -64,10 +80,8 @@ int main(int argc, char *argv[])
psi.write(); psi.write();
if (!args.optionFound("noH")) if (!args.optionFound("noH") || args.optionFound("HdotGradH"))
{ {
Info<< nl
<< "Creating field H for time " << runTime.timeName() << endl;
volVectorField H volVectorField H
( (
IOobject IOobject
@ -79,13 +93,42 @@ int main(int argc, char *argv[])
fvc::reconstruct(fvc::snGrad(psi)*mesh.magSf()) fvc::reconstruct(fvc::snGrad(psi)*mesh.magSf())
); );
if (!args.optionFound("noH"))
{
Info<< nl
<< "Creating field H for time "
<< runTime.timeName() << endl;
H.write(); H.write();
} }
if (args.optionFound("HdotGradH"))
{
Info<< nl
<< "Creating field HdotGradH for time "
<< runTime.timeName() << endl;
volVectorField HdotGradH
(
IOobject
(
"HdotGradH",
runTime.timeName(),
mesh
),
H & fvc::grad(H)
);
HdotGradH.write();
}
}
if (!args.optionFound("noB")) if (!args.optionFound("noB"))
{ {
Info<< nl Info<< nl
<< "Creating field B for time " << runTime.timeName() << endl; << "Creating field B for time "
<< runTime.timeName() << endl;
volVectorField B volVectorField B
( (
IOobject IOobject

View File

@ -64,13 +64,13 @@ namespace Foam
// Hack to do zones which have Lists in them. See above. // Hack to do zones which have Lists in them. See above.
bool writeZones(const word& name, Time& runTime) bool writeZones(const word& name, const fileName& meshDir, Time& runTime)
{ {
IOobject io IOobject io
( (
name, name,
runTime.timeName(), runTime.timeName(),
polyMesh::meshSubDir, meshDir,
runTime, runTime,
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
@ -144,8 +144,20 @@ bool writeZones(const word& name, Time& runTime)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
timeSelector::addOptions(); timeSelector::addOptions();
# include "addRegionOption.H"
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"
fileName meshDir = polyMesh::meshSubDir;
fileName regionPrefix = "";
word regionName = polyMesh::defaultRegion;
if (args.optionReadIfPresent("region", regionName))
{
Info<< "Using region " << regionName << nl << endl;
regionPrefix = regionName;
meshDir = regionName/polyMesh::meshSubDir;
}
Foam::instantList timeDirs = Foam::timeSelector::select0(runTime, args); Foam::instantList timeDirs = Foam::timeSelector::select0(runTime, args);
forAll(timeDirs, timeI) forAll(timeDirs, timeI)
@ -154,27 +166,32 @@ int main(int argc, char *argv[])
Info<< "Time = " << runTime.timeName() << endl; Info<< "Time = " << runTime.timeName() << endl;
// Convert all the standard mesh files // Convert all the standard mesh files
writeMeshObject<cellIOList>("cells", runTime); writeMeshObject<cellIOList>("cells", meshDir, runTime);
writeMeshObject<labelIOList>("owner", runTime); writeMeshObject<labelIOList>("owner", meshDir, runTime);
writeMeshObject<labelIOList>("neighbour", runTime); writeMeshObject<labelIOList>("neighbour", meshDir, runTime);
writeMeshObject<faceIOList>("faces", runTime); writeMeshObject<faceIOList>("faces", meshDir, runTime);
writeMeshObject<pointIOField>("points", runTime); writeMeshObject<pointIOField>("points", meshDir, runTime);
writeMeshObject<labelIOList>("pointProcAddressing", runTime); writeMeshObject<labelIOList>("pointProcAddressing", meshDir, runTime);
writeMeshObject<labelIOList>("faceProcAddressing", runTime); writeMeshObject<labelIOList>("faceProcAddressing", meshDir, runTime);
writeMeshObject<labelIOList>("cellProcAddressing", runTime); writeMeshObject<labelIOList>("cellProcAddressing", meshDir, runTime);
writeMeshObject<labelIOList>("boundaryProcAddressing", runTime); writeMeshObject<labelIOList>
(
"boundaryProcAddressing",
meshDir,
runTime
);
if (runTime.writeFormat() == IOstream::ASCII) if (runTime.writeFormat() == IOstream::ASCII)
{ {
// Only do zones when converting from binary to ascii // Only do zones when converting from binary to ascii
// The other way gives problems since working on dictionary level. // The other way gives problems since working on dictionary level.
writeZones("cellZones", runTime); writeZones("cellZones", meshDir, runTime);
writeZones("faceZones", runTime); writeZones("faceZones", meshDir, runTime);
writeZones("pointZones", runTime); writeZones("pointZones", meshDir, runTime);
} }
// Get list of objects from the database // Get list of objects from the database
IOobjectList objects(runTime, runTime.timeName()); IOobjectList objects(runTime, runTime.timeName(), regionPrefix);
forAllConstIter(IOobjectList, objects, iter) forAllConstIter(IOobjectList, objects, iter)
{ {

View File

@ -40,13 +40,18 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class T> template<class T>
inline bool writeMeshObject(const word& name, Time& runTime) inline bool writeMeshObject
(
const word& name,
const fileName& meshDir,
Time& runTime
)
{ {
IOobject io IOobject io
( (
name, name,
runTime.timeName(), runTime.timeName(),
polyMesh::meshSubDir, meshDir,
runTime, runTime,
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,

View File

@ -96,7 +96,7 @@ case OpenFOAM:
set gcc_version=gcc-4.5.0 set gcc_version=gcc-4.5.0
set gmp_version=gmp-5.0.1 set gmp_version=gmp-5.0.1
set mpfr_version=mpfr-2.4.2 set mpfr_version=mpfr-2.4.2
set mpc_version=mpc-2.4.2 set mpc_version=mpc-0.8.1
breaksw breaksw
case Gcc44: case Gcc44:
set gcc_version=gcc-4.4.3 set gcc_version=gcc-4.4.3
@ -121,7 +121,10 @@ case OpenFOAM:
set gccDir=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH/$gcc_version set gccDir=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH/$gcc_version
set gmpDir=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH/$gmp_version set gmpDir=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH/$gmp_version
set mpfrDir=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH/$mpfr_version set mpfrDir=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH/$mpfr_version
if ( $?mpc_version ) then
set mpcDir=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH/$mpc_version set mpcDir=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH/$mpc_version
endif
# Check that the compiler directory can be found # Check that the compiler directory can be found
if ( ! -d "$gccDir" ) then if ( ! -d "$gccDir" ) then

View File

@ -75,7 +75,7 @@ inline Foam::KinematicParcel<ParcelType>::KinematicParcel
) )
: :
Particle<ParcelType>(owner, position, cellI), Particle<ParcelType>(owner, position, cellI),
active_(false), active_(true),
typeId_(owner.parcelTypeId()), typeId_(owner.parcelTypeId()),
nParticle_(0), nParticle_(0),
d_(0.0), d_(0.0),

View File

@ -83,7 +83,7 @@ Foam::KinematicParcel<ParcelType>::KinematicParcel
{ {
is.read is.read
( (
reinterpret_cast<char*>(&typeId_), reinterpret_cast<char*>(&active_),
sizeof(active_) sizeof(active_)
+ sizeof(typeId_) + sizeof(typeId_)
+ sizeof(nParticle_) + sizeof(nParticle_)

View File

@ -101,10 +101,10 @@ Foam::sixDoFRigidBodyMotionRestraints::linearAxialAngularSpring::restrain
// Removing any axis component from oldDir and newDir and normalising // Removing any axis component from oldDir and newDir and normalising
oldDir -= (axis_ & oldDir)*axis_; oldDir -= (axis_ & oldDir)*axis_;
oldDir /= mag(oldDir); oldDir /= (mag(oldDir) + VSMALL);
newDir -= (axis_ & newDir)*axis_; newDir -= (axis_ & newDir)*axis_;
newDir /= mag(newDir); newDir /= (mag(newDir) + VSMALL);
scalar theta = mag(acos(min(oldDir & newDir, 1.0))); scalar theta = mag(acos(min(oldDir & newDir, 1.0)));

View File

@ -86,7 +86,7 @@ void Foam::sixDoFRigidBodyMotionRestraints::linearSpring::restrain
scalar magR = mag(r); scalar magR = mag(r);
// r is now the r unit vector // r is now the r unit vector
r /= magR; r /= (magR + VSMALL);
vector v = motion.currentVelocity(restraintPosition); vector v = motion.currentVelocity(restraintPosition);

View File

@ -103,10 +103,10 @@ Foam::sixDoFRigidBodyMotionRestraints::tabulatedAxialAngularSpring::restrain
// Removing any axis component from oldDir and newDir and normalising // Removing any axis component from oldDir and newDir and normalising
oldDir -= (axis_ & oldDir)*axis_; oldDir -= (axis_ & oldDir)*axis_;
oldDir /= mag(oldDir); oldDir /= (mag(oldDir) + VSMALL);
newDir -= (axis_ & newDir)*axis_; newDir -= (axis_ & newDir)*axis_;
newDir /= mag(newDir); newDir /= (mag(newDir) + VSMALL);
scalar theta = mag(acos(min(oldDir & newDir, 1.0))); scalar theta = mag(acos(min(oldDir & newDir, 1.0)));

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\ /*--------------------------------*- C++ -*----------------------------------*\
| ========= | | | ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev | | \\ / O peration | Version: 1.6.x |
| \\ / A nd | Web: www.OpenFOAM.org | | \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | | | \\/ M anipulation | |
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/