Skip to content

Commit

Permalink
Refinement Controller (#10)
Browse files Browse the repository at this point in the history
* Basic refinement field class written but not compiled or tested. Pausing work to implement helper functions in the beam segment class.

* Beam helper functions

* Refinement control scheme compiles, not tested

* Additional conditionals, now works with the AMB-2018 case

* Fixes to persistence feature

* Fixed uniformIntervals and added tutorial

* Address review
  • Loading branch information
kincaidkc authored Feb 9, 2024
1 parent 409c6b5 commit 9dd20c4
Show file tree
Hide file tree
Showing 31 changed files with 1,679 additions and 27 deletions.
20 changes: 14 additions & 6 deletions applications/solvers/additiveFoam/additiveFoam.C
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Description
#include "movingHeatSourceModel.H"
#include "foamToExaCA/foamToExaCA.H"

//#include "Timer.H" // for profiling, if desired
#include "utils/Timer.H" // for profiling, if desired

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

Expand All @@ -72,7 +72,7 @@ int main(int argc, char *argv[])
#include "initContinuityErrs.H"

// Initialize profiling timer
//Timers timer(runTime);
Timers timer(runTime);

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

Expand All @@ -96,11 +96,17 @@ int main(int argc, char *argv[])
#include "CourantNo.H"
#include "setDeltaT.H"

//timer.start("Heat Source");
timer.start("Heat Source");
sources.update();
//timer.stop("Heat Source");
timer.stop("Heat Source");

mesh.update();
timer.start("Refinement Control and Mesh Update");
if (sources.refinementControl().update())
{
Info << "Calling mesh.update()" << endl;
mesh.update();
}
timer.stop("Refinement Control and Mesh Update");

runTime++;

Expand All @@ -119,7 +125,9 @@ int main(int argc, char *argv[])
}
}

timer.start("TEqn");
#include "thermo/TEqn.H"
timer.stop("TEqn");

ExaCA.update();

Expand All @@ -138,7 +146,7 @@ int main(int argc, char *argv[])
ExaCA.write();

// Write time profiling information
//timer.write();
timer.write();

return 0;
}
Expand Down
4 changes: 4 additions & 0 deletions applications/solvers/additiveFoam/movingHeatSource/Make/files
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ heatSourceModels/heatSourceModel/heatSourceModelNew.C
heatSourceModels/superGaussian/superGaussian.C
heatSourceModels/modifiedSuperGaussian/modifiedSuperGaussian.C

refinementControllers/refinementController/refinementController.C
refinementControllers/refinementController/refinementControllerNew.C
refinementControllers/uniformIntervals/uniformIntervals.C

movingHeatSourceModel/movingHeatSourceModel.C

LIB = $(FOAM_USER_LIBBIN)/libmovingBeamModels
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ EXE_INC = \
-IheatSourceModels \
-IabsorptionModels \
-Isegment \
-IrefinementControllers \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/OpenFOAM/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public:
// Member Functions

//- Return access to the movingBeam instance
movingBeam& beam()
const movingBeam& beam() const
{
return movingBeam_();
}
Expand All @@ -179,7 +179,7 @@ public:
}

//- Return vector of current heat source dimensions
vector dimensions()
const vector dimensions() const
{
return dimensions_;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Foam::movingBeam::movingBeam

// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //

inline Foam::vector
Foam::vector
Foam::movingBeam::position(const scalar time) const
{
if (activePath(time))
Expand Down Expand Up @@ -119,7 +119,7 @@ Foam::movingBeam::position(const scalar time) const
}


inline Foam::scalar
Foam::scalar
Foam::movingBeam::power(const scalar time) const
{
if (activePath(time))
Expand All @@ -142,7 +142,7 @@ Foam::movingBeam::power(const scalar time) const
}


inline Foam::scalar
Foam::scalar
Foam::movingBeam::mode(const scalar time) const
{
if (activePath(time))
Expand All @@ -158,7 +158,7 @@ Foam::movingBeam::mode(const scalar time) const
}


inline Foam::scalar
Foam::scalar
Foam::movingBeam::parameter(const scalar time) const
{
if (activePath(time))
Expand All @@ -174,7 +174,7 @@ Foam::movingBeam::parameter(const scalar time) const
}


inline Foam::scalar
Foam::scalar
Foam::movingBeam::velocity(const scalar time) const
{
if (activePath(time))
Expand Down Expand Up @@ -302,7 +302,7 @@ bool Foam::movingBeam::activePath(const scalar time) const
}


void Foam::movingBeam::move(const scalar time)
void Foam::movingBeam::move(const scalar time) const
{
// update the current index of the path
index_ = findIndex(time);
Expand Down Expand Up @@ -373,7 +373,7 @@ Foam::movingBeam::findIndex(const scalar time) const
}


void Foam::movingBeam::adjustDeltaT(scalar& dt)
void Foam::movingBeam::adjustDeltaT(scalar& dt) const
{
if (activePath() && hitPathIntervals_)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ private:
DynamicList<segment> path_;

//- Index of path
label index_;
mutable label index_;

//- Position of beam
vector position_;
mutable vector position_;

//- Power of beam
scalar power_;
mutable scalar power_;

//- End time of path
scalar endTime_;
Expand Down Expand Up @@ -168,19 +168,19 @@ public:
}

//- Return position at specified time
inline vector position(const scalar time) const;
vector position(const scalar time) const;

//- Return power at specified time
inline scalar power(const scalar time) const;
scalar power(const scalar time) const;

//- Return beam mode at specified time
inline scalar mode(const scalar time) const;
scalar mode(const scalar time) const;

//- Return beam parameter at specified time
inline scalar parameter(const scalar time) const;
scalar parameter(const scalar time) const;

//- Return beam velocity at specified time
inline scalar velocity(const scalar time) const;
scalar velocity(const scalar time) const;

//- Return time of next path start
scalar timeToNextPath(const scalar time) const;
Expand All @@ -195,13 +195,13 @@ public:
bool activePath(const scalar time) const;

//- Move the beam to the provided time
void move(const scalar time);
void move(const scalar time) const;

//- Returns the path index at the provided time
label findIndex(const scalar time) const;

//- Adjust solution time step to hit pathInterval
void adjustDeltaT(scalar& dt);
void adjustDeltaT(scalar& dt) const;
};


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ Foam::movingHeatSourceModel::movingHeatSourceModel
),
mesh_,
dimensionedScalar(dimPower/dimVolume, 0.0)
)
),
refinementController_(nullptr)
{
sources_.resize(sourceNames_.size());

Expand All @@ -80,6 +81,9 @@ Foam::movingHeatSourceModel::movingHeatSourceModel
).ptr()
);
}

refinementController_ =
refinementController::New(sources_, dict_, mesh_);
}

// * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * * //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ SourceFiles

#include "heatSourceModel.H"
#include "movingBeam.H"
#include "refinementController.H"

namespace Foam
{

/*---------------------------------------------------------------------------*\
Class movingHeatSourceModel Declaration
Class movingHeatSourceModel Declaration
\*---------------------------------------------------------------------------*/

class movingHeatSourceModel
Expand All @@ -70,6 +71,9 @@ private:

//- Pointer list to each beam instance
PtrList<heatSourceModel> sources_;

//- Pointer to refinement controller
autoPtr<refinementController> refinementController_;

public:

Expand All @@ -92,6 +96,12 @@ public:
return qDot_;
}

//- Return pointer to the refinement controller
refinementController& refinementControl()
{
return refinementController_();
}

//- Adjust deltaT using the current state of each beam
void adjustDeltaT(scalar& deltaT);

Expand Down
Loading

0 comments on commit 9dd20c4

Please sign in to comment.