91 std::unique_ptr<DofManager> dman(
classFactory.createDofManager(
"node", nodeId, d ) );
99 dman->setCoordinates( coords );
100 dman->setGlobalNumber( nodeId );
106 int setId = nSetsBefore + 1;
108 std::unique_ptr<Set> set = std::make_unique<Set>( setId, d );
110 set->setNumber( setId );
111 set->setNodeList( nodeIds );
112 d->
setSet( setId, std::move( set ) );
119 int ICId = nICBefore + 1;
121 std::unique_ptr<InitialCondition> ic = std::make_unique<InitialCondition>( ICId, d );
125 props.
add(
'u', this->
printer.depositionTemperature );
131 ic->initializeFrom( icInput );
135 if ( coords[2] <= 1e-12 ) {
139 int bcId = nBCBefore + 1;
141 std::unique_ptr<GeneralBoundaryCondition> bc(
classFactory.createBoundaryCondition(
"BoundaryCondition", bcId, d ) );
152 bc->initializeFrom( myInput );
154 bc->setNumber( bcId );
155 bc->postInitialize();
165 std::unique_ptr<CalculatorFunction> tf = std::make_unique<CalculatorFunction>( nTFBefore + 1, d );
169 tf->initializeFrom( myInput );
175 int bcId = nBCBefore + 1;
178 std::unique_ptr<GeneralBoundaryCondition> bc(
classFactory.createBoundaryCondition(
"BoundaryCondition", bcId, d ) );
190 bc->initializeFrom( myInput2 );
192 bc->setNumber( bcId );
193 bc->postInitialize();
201 dman->appendDof( dof );
202 dman->postInitialize();
216 std::unique_ptr<Element> elem(
classFactory.createElement(
"brick1ht", elId, d ) );
218 OOFEM_ERROR(
"Couldn't create element %d\n", elId );
226 elem->setDofManagers( enodes );
227 elem->setGlobalNumber( elId );
228 elem->setCrossSection( 1 );
230 elem->postInitialize();
234 std::unique_ptr<HeavisideTimeFunction> tf = std::make_unique<HeavisideTimeFunction>( nTFBefore + 1, d );
239 tf->initializeFrom( myInput );
240 elem->setActivityTimeFunctionNumber( nTFBefore + 1 );
254 for (
int i = 0; i < 6; i++ ) {
255 int setId = nSetsBefore + 1 + i;
257 std::unique_ptr<Set> set = std::make_unique<Set>( setId, d );
259 set->setNumber( setId );
260 set->setBoundaryList( bounds );
262 d->
setSet( setId, std::move( set ) );
264 int bcid = nBCBefore + 1 + i;
265 std::unique_ptr<GeneralBoundaryCondition> bc(
classFactory.createBoundaryCondition(
"freeconstantsurfaceload", bcid, d ) );
271 props.
add(
'a', this->
printer.heatTransferFilmCoefficient );
279 bc->initializeFrom( myInput );
281 bc->setNumber( bcid );
282 bc->postInitialize();
292 std::unique_ptr<StepFunction> tf2 = std::make_unique<StepFunction>( nTFBefore + 1, d, cn.
vofHistory );
299 std::unique_ptr<DepositedHeatSource> load = std::make_unique<DepositedHeatSource>( nBCBefore+1, d, 0,
300 this->
printer.depositedMaterialHeatPower,
301 this->printer.depositionTemperature,
324 std::unique_ptr<DofManager> dman(
classFactory.createDofManager(
"node", nodeId, d ) );
326 OOFEM_ERROR(
"Couldn't create node %d\n", nodeId );
337 dman->setCoordinates( coords );
338 dman->setGlobalNumber( nodeId );
350 if ( coords[2] <= 1e-12 ) {
365 int setId = nSetsBefore + 1;
367 std::unique_ptr<Set> set = std::make_unique<Set>( setId, d );
369 set->setNumber( setId );
370 set->setNodeList( nodeIds );
371 d->
setSet( setId, std::move( set ) );
376 bcId = nBCBefore + 1;
378 std::unique_ptr<GeneralBoundaryCondition> bc(
classFactory.createBoundaryCondition(
"BoundaryCondition", bcId, d ) );
389 bc->initializeFrom( myInput );
391 bc->setNumber( bcId );
392 bc->postInitialize();
407 int setId = nSetsBefore + 1;
409 std::unique_ptr<Set> set = std::make_unique<Set>( setId, d );
411 set->setNumber( setId );
412 set->setNodeList( nodeIds );
413 d->
setSet( setId, std::move( set ) );
418 std::unique_ptr<CalculatorFunction> tf = std::make_unique<CalculatorFunction>( nTFBefore + 1, d );
425 tf->initializeFrom( myInput );
432 int bcId = nBCBefore + 1;
434 std::unique_ptr<GeneralBoundaryCondition> bc(
classFactory.createBoundaryCondition(
"BoundaryCondition", bcId, d ) );
446 bc->initializeFrom( myInput2 );
448 bc->setNumber( bcId );
450 bc->postInitialize();
459 dman->appendDof( dofU );
460 dman->appendDof( dofV );
461 dman->appendDof( dofW );
478 std::unique_ptr<Element> elem(
classFactory.createElement(
"LSpace", elId, d ) );
480 OOFEM_ERROR(
"Couldn't create element %d\n", elId );
490 std::unique_ptr<HeavisideTimeFunction> tf = std::make_unique<HeavisideTimeFunction>( nTFBefore + 1, d );
495 tf->initializeFrom( myInput );
496 elem->setActivityTimeFunctionNumber( nTFBefore + 1 );
500 elem->setDofManagers( enodes );
501 elem->setGlobalNumber( elId );
502 elem->setCrossSection( 1 );
504 elem->postInitialize();
509AdditiveManufacturingProblem ::AdditiveManufacturingProblem(
int i,
EngngModel *_master ) :
530AdditiveManufacturingProblem ::~AdditiveManufacturingProblem()
547int AdditiveManufacturingProblem ::instanciateDefaultMetaStep(
InputRecord &ir )
555 EngngModel ::instanciateDefaultMetaStep( ir );
560int AdditiveManufacturingProblem ::instanciateSlaveProblems()
587void AdditiveManufacturingProblem ::initializeFrom(
InputRecord &ir )
603 po.
sizes = { (int)std::ceil( 250.0 / po.
steps[0] ),
604 (int)std::ceil( 250.0 / po.
steps[1] ),
605 (int)std::ceil( 250.0 / po.
steps[2] ) };
622 double queue_size = 3;
624 for (
int i = 1; i < queue_size; i++ ) {
625 pr.addCommandToQueue( commands[i] );
628 std::size_t csize = commands.size();
630 csize = this->maxPrinterCommands;
631 OOFEM_LOG_INFO(
"Limiting number of processed commands to %d\n", this->maxPrinterCommands );
640 for (
size_t i = 0; i < csize; i++ ) {
641 size_t j = i + queue_size;
643 pr.processCommand( commands[i] );
645 if ( j < commands.size() )
646 pr.addCommandToQueue( commands[j] );
648 pr.popCommandFromQueue();
650 double p = (double)(i+1) / (double)csize;
651 if (
int(100*p) >
int(100*progress) ) {
668 pr.getGrid().writeVTK(
"voxel_vof.vtk");
675 EngngModel ::initializeFrom( ir );
679 EngngModel ::initializeFrom( ir );
739 printf(
"Suppressing output.\n" );
750#ifdef __MPI_PARALLEL_MODE
759void AdditiveManufacturingProblem ::updateAttributes(
MetaStep *mStep )
763 EngngModel ::updateAttributes( mStep );
767 emodel->updateAttributes( mStep );
784Function *AdditiveManufacturingProblem ::giveDtFunction()
795AdditiveManufacturingProblem ::giveDeltaT(
int n )
815 double adjustedDeltaT =
deltaT;
821 if ( !(
currentStep->giveTargetTime() > this->adaptiveStepSince ) ) {
822 return adjustedDeltaT;
848 return adjustedDeltaT;
855AdditiveManufacturingProblem ::giveDiscreteTime(
int iStep )
857 if ( ( iStep > 0 ) && ( iStep <=
discreteTimes.giveSize() ) ) {
861 if ( ( iStep == 0 ) && ( iStep <=
discreteTimes.giveSize() ) ) {
870AdditiveManufacturingProblem ::giveCurrentStep(
bool force )
875 return EngngModel ::giveCurrentStep();
880AdditiveManufacturingProblem ::givePreviousStep(
bool force )
885 return EngngModel ::givePreviousStep();
890AdditiveManufacturingProblem ::giveSolutionStepWhenIcApply(
bool force )
907AdditiveManufacturingProblem ::giveTimeControl()
917int AdditiveManufacturingProblem ::giveNumberOfFirstStep(
bool force )
922 return EngngModel ::giveNumberOfFirstStep( force );
928AdditiveManufacturingProblem ::giveNextStep()
931 double totalTime = 0;
942 counter =
currentStep->giveSolutionStateCounter() + 1;
948 OOFEM_LOG_INFO(
"\n==================================================================\n" );
950 currentStep = std::make_unique<TimeStep>( istep,
this, 1, totalTime, totalTime -
previousStep->giveTargetTime(), counter );
954 OOFEM_LOG_INFO(
"\n==================================================================\n" );
957 currentStep = std::make_unique<TimeStep>( istep,
this, 1, totalTime, totalTime -
previousStep->giveTargetTime(), counter );
965void AdditiveManufacturingProblem ::solveYourself()
970 int smstep = 1, sjstep = 1;
971 this->
timer.startTimer( EngngModelTimer ::EMTT_AnalysisTimer );
979 std::cout <<
"#3d printing TM elements " <<
printer.getGrid().active_elements() << std::endl;
980 std::cout <<
"#3d printing TM nodes " <<
printer.getGrid().active_nodes() << std::endl;
986 for (
auto &n : this->
printer.getGrid().giveNodes() ) {
990 for (
auto &n : this->
printer.getGrid().giveVoxels() ) {
1000 std::cout <<
"#3d printing SM elements " <<
printer.getGrid().active_elements() << std::endl;
1001 std::cout <<
"#3d printing SM nodes " <<
printer.getGrid().active_nodes() << std::endl;
1007 for (
auto &n : this->
printer.getGrid().giveNodes() ) {
1011 for (
auto &n : this->
printer.getGrid().giveVoxels() ) {
1033 for (
int jstep = sjstep; jstep <= nTimeSteps; jstep++ ) {
1034 this->
timer.startTimer( EngngModelTimer ::EMTT_SolutionStepTimer );
1035 this->
timer.initTimer( EngngModelTimer ::EMTT_NetComputationalStepTimer );
1061 this->timer.
stopTimer( EngngModelTimer ::EMTT_SolutionStepTimer );
1062 double _steptime = this->timer.
getUtime( EngngModelTimer ::EMTT_SolutionStepTimer );
1063 OOFEM_LOG_INFO(
"EngngModel info: user time consumed by solution step %d: %.2fs\n",
1067 fprintf( this->
giveOutputStream(),
"\nUser time consumed by solution step %d: %.3f [s]\n\n",
1071#ifdef __MPI_PARALLEL_MODE
1085void AdditiveManufacturingProblem ::solveYourselfAt(
TimeStep *tStep )
1092 emodel->solveYourselfAt( tStep );
1098int AdditiveManufacturingProblem ::forceEquationNumbering()
1103 if ( emodel->requiresEquationRenumbering( emodel->giveCurrentStep() ) ) {
1104 neqs += emodel->forceEquationNumbering();
1111void AdditiveManufacturingProblem ::updateYourself(
TimeStep *tStep )
1118 emodel->updateYourself( tStep );
1121 EngngModel ::updateYourself( tStep );
1124void AdditiveManufacturingProblem ::terminate(
TimeStep *tStep )
1127 emodel->terminate( tStep );
1131void AdditiveManufacturingProblem ::doStepOutput(
TimeStep *tStep )
1134 emodel->giveExportModuleManager()->doOutput( tStep );
1139void AdditiveManufacturingProblem ::printOutputAt( FILE *file,
TimeStep *tStep )
1147 EngngModel ::saveContext( stream, mode );
1149 emodel->saveContext( stream, mode );
1156 EngngModel ::restoreContext( stream, mode );
1158 emodel->restoreContext( stream, mode );
1164AdditiveManufacturingProblem ::giveSlaveProblem(
int i )
1176int AdditiveManufacturingProblem ::checkProblemConsistency()
1182 result &= emodel->checkProblemConsistency();
1198void AdditiveManufacturingProblem ::updateDomainLinks()
1201 emodel->updateDomainLinks();
1205void AdditiveManufacturingProblem ::setRenumberFlag()
1208 emodel->setRenumberFlag();
1215 int ap =
gc.getActiveProblemIndx();
1223 int ap =
gc.getActiveProblemIndx();
1231 int ap =
gc.getActiveProblemIndx();
#define _IFT_AdditiveManufacturingProblem_Printer_extrusionwidth
#define _IFT_AdditiveManufacturingProblem_prob1
#define _IFT_AdditiveManufacturingProblem_stepmultiplier
#define _IFT_AdditiveManufacturingProblem_stepy
#define _IFT_AdditiveManufacturingProblem_stepz
#define _IFT_AdditiveManufacturingProblem_reqiterations
#define _IFT_AdditiveManufacturingProblem_skipsm
#define _IFT_AdditiveManufacturingProblem_Printer_heatbedtemperature
#define _IFT_AdditiveManufacturingProblem_prob3
#define _IFT_AdditiveManufacturingProblem_coupling
#define _IFT_AdditiveManufacturingProblem_prob2
#define _IFT_AdditiveManufacturingProblem_adaptiveStepLength
#define _IFT_AdditiveManufacturingProblem_minvof
#define _IFT_AdditiveManufacturingProblem_maxsteplength
#define _IFT_AdditiveManufacturingProblem_endoftimeofinterest
#define _IFT_AdditiveManufacturingProblem_Printer_depositedmaterialheatpower
#define _IFT_AdditiveManufacturingProblem_Printer_heattransferfilmcoefficient
#define _IFT_AdditiveManufacturingProblem_Printer_chambertemperature
#define _IFT_AdditiveManufacturingProblem_maxprintercommands
#define _IFT_AdditiveManufacturingProblem_dtf
#define _IFT_AdditiveManufacturingProblem_deltat
#define _IFT_AdditiveManufacturingProblem_gcode
#define _IFT_AdditiveManufacturingProblem_prescribedtimes
#define _IFT_AdditiveManufacturingProblem_minsteplength
#define _IFT_AdditiveManufacturingProblem_adaptivestepsince
#define _IFT_AdditiveManufacturingProblem_Printer_layerheight
#define _IFT_AdditiveManufacturingProblem_Printer_depositiontemperature
#define _IFT_AdditiveManufacturingProblem_stepx
#define _IFT_AdditiveManufacturingProblem_timeDefinedByProb
#define _IFT_BoundaryCondition_Name
#define _IFT_BoundaryCondition_values
[ra,optional] Vector of prescribed values for each respective DOF.
#define _IFT_BoundaryLoad_properties
#define _IFT_BoundaryLoad_loadtype
#define _IFT_CalculatorFunction_f
#define _IFT_CalculatorFunction_Name
The GCodeParser class is used to parse G-code files.
std::vector< GCodeCommand > parseFile(const std::string &filename)
Parses a file and returns a vector of GCodeCommand objects.
The Printer class is used to process G-code commands and manage the printer state.
#define REGISTER_EngngModel(class)
std ::vector< std ::string > inputStreamNames
double endOfTimeOfInterest
Function * giveDtFunction()
bool add_sm_node_if_not_exists2(EngngModel *emodel, const VoxelNode &cn)
FloatArray discreteTimes
Specified times where the problem is solved.
IntArray coupledModels
List of slave models to which this model is coupled.
double giveDiscreteTime(int n)
double maxStepLength
adaptive time step length - maximum
void terminate(TimeStep *tStep) override
double reqIterations
adaptive time step length - required (=optimum) number of iterations
double adaptiveStepSince
adaptive time step length applies after prescribed time
void add_element_if_not_exists2(EngngModel *emodel, Voxel &cn)
int forceEquationNumbering() override
int giveNumberOfFirstStep(bool force=false) override
EngngModel * giveTimeControl()
void initializeYourself(TimeStep *tStep) override
void solveYourselfAt(TimeStep *tStep) override
int instanciateSlaveProblems()
std::string gCodeFilePath
bool add_node_if_not_exists2(EngngModel *emodel, const VoxelNode &cn)
TimeStep * giveSolutionStepWhenIcApply(bool force=false) override
std ::vector< std ::unique_ptr< EngngModel > > emodelList
List of engineering models to solve sequentially.
int timeDefinedByProb
Optional parameter which specify problems to define load time functions.
void add_sm_element_if_not_exists2(EngngModel *emodel, Voxel &cn)
EngngModel * giveSlaveProblem(int i) override
Returns i-th slave problem.
void updateYourself(TimeStep *tStep) override
std ::shared_ptr< VoxelVOFField > voxelVofField
int giveNumberOfSlaveProblems() override
Returns number of slave problems.
double minStepLength
adaptive time step length - minimum
int dtFunction
Associated time function for time step increment.
void reset()
reset receiver to an initial state (will force table update, when needed next time)
Pair * add(int aKey, double value)
virtual void setBcId(int bcId)
Overwrites the boundary condition id (0-inactive BC), intended for specific purposes such as coupling...
std ::vector< std ::unique_ptr< DofManager > > dofManagerList
Dof manager list.
void setSet(int i, std::unique_ptr< Set > obj)
Sets i-th component. The component will be further managed and maintained by domain object.
void resizeDofManagers(int _newSize)
Resizes the internal data structure to accommodate space for _newSize dofManagers.
int giveNumberOfBoundaryConditions() const
Returns number of boundary conditions in domain.
void resizeElements(int _newSize)
Resizes the internal data structure to accommodate space for _newSize elements.
void setElement(int i, std::unique_ptr< Element > obj)
Sets i-th component. The component will be further managed and maintained by domain object.
ConnectivityTable * giveConnectivityTable()
void resizeBoundaryConditions(int _newSize)
Resizes the internal data structure to accommodate space for _newSize boundary conditions.
void resizeInitialConditions(int _newSize)
Resizes the internal data structure to accommodate space for _newSize initial conditions.
int giveNumberOfInitialConditions() const
Returns number of initial conditions in domain.
int giveNumberOfSets() const
Returns number of sets.
void setFunction(int i, std::unique_ptr< Function > obj)
Sets i-th component. The component will be further managed and maintained by domain object.
void resizeSets(int _newSize)
Resizes the internal data structure to accommodate space for _newSize sets.
Element * giveElement(int n)
void setBoundaryCondition(int i, std::unique_ptr< GeneralBoundaryCondition > obj)
Sets i-th component. The component will be further managed and maintained by domain object.
void setDofManager(int i, std::unique_ptr< DofManager > obj)
Sets i-th component. The component will be further managed and maintained by domain object.
void resizeFunctions(int _newSize)
Resizes the internal data structure to accommodate space for _newSize load time functions.
std ::vector< std ::unique_ptr< Element > > elementList
Element list.
void setInitialCondition(int i, std::unique_ptr< InitialCondition > obj)
Sets i-th component. The component will be further managed and maintained by domain object.
int giveNumberOfFunctions() const
Returns number of load time functions in domain.
void setBodyLoads(const IntArray &bodyLoads)
int giveNumberOfTimeStepWhenIcApply()
Returns the time step number, when initial conditions should apply.
std ::vector< std ::unique_ptr< Domain > > domainList
List of problem domains.
virtual void preInitializeNextStep()
Does a pre-initialization of the next time step (implement if necessarry).
int numProcs
Total number of collaborating processes.
virtual int giveCurrentNumberOfIterations()
virtual void balanceLoad(TimeStep *tStep)
int rank
Domain rank in a group of collaborating processes (0..groupSize-1).
virtual TimeStep * giveCurrentStep(bool force=false)
std::string dataOutputFileName
Path to output stream.
ExportModuleManager * giveExportModuleManager()
Returns receiver's export module manager.
std::string simulationDescription
virtual TimeStep * giveNextStep()
Returns next time step (next to current step) of receiver.
EngngModelContext * giveContext()
Context requesting service.
bool renumberFlag
Renumbering flag (renumbers equations after each step, necessary if Dirichlet BCs change).
EngngModel(int i, EngngModel *_master=NULL)
std ::unique_ptr< TimeStep > previousStep
Previous time step.
char processor_name[PROCESSOR_NAME_LENGTH]
Processor name.
int ndomains
Number of receiver domains.
int numberOfSteps
Total number of time steps.
Domain * giveDomain(int n)
std ::unique_ptr< TimeStep > currentStep
Current time step.
bool loadBalancingFlag
If set to true, load balancing is active.
FILE * giveOutputStream()
Returns file descriptor of output file.
time_t startTime
Solution start time.
MetaStep * giveMetaStep(int i)
Returns the i-th meta step.
EngngModelTimer timer
E-model timer.
problemMode pMode
Domain mode.
ContextOutputMode contextOutputMode
Domain context output mode.
void initMetaStepAttributes(MetaStep *mStep)
int giveNumberOfMetaSteps()
Return number of meta steps.
bool suppressOutput
Flag for suppressing output to file.
FILE * outputStream
Output stream.
bool isParallel() const
Returns true if receiver in parallel mode.
std ::unique_ptr< TimeStep > stepWhenIcApply
Solution step when IC (initial conditions) apply.
virtual bool requiresEquationRenumbering(TimeStep *tStep)
IntArray domainPrescribedNeqs
Number of prescribed equations per domain.
IntArray domainNeqs
Number of equations per domain.
virtual void initialize()
int giveNumberOfModules() const
int giveMetaStepNumber()
Returns receiver's meta step number.
void incrementStateCounter()
Updates solution state counter.
double giveTargetTime()
Returns target time.
int giveNumber()
Returns receiver's number.
double getUtime()
Returns total user time elapsed in seconds.
#define _IFT_EngngModel_nsteps
#define _IFT_EngngModel_suppressOutput
#define _IFT_FreeConstantSurfaceLoad_Name
#define _IFT_GeneralBoundaryCondition_set
#define _IFT_GeneralBoundaryCondition_timeFunct
#define _IFT_GeneralBoundaryCondition_dofs
#define _IFT_GeneralBoundaryCondition_isImposedTimeFunct
#define _IFT_HeavisideTimeFunction_value
#define _IFT_HeavisideTimeFunction_Name
#define _IFT_HeavisideTimeFunction_origin
#define _IFT_InitialCondition_Name
#define _IFT_InitialCondition_conditions
#define _IFT_InitialCondition_dofs
#define _IFT_InitialCondition_set
#define _IFT_Load_components
#define OOFEM_LOG_INFO(...)
#define OOFEM_LOG_RELEVANT(...)
#define OOFEM_LOG_DEBUG(...)
void printProgress(double percentage, const std::string &title, std::ostream &out)
@ Element_local
Element is local, there are no contributions from other domains to this element.
long StateCounterType
StateCounterType type used to indicate solution state.
FloatArrayF< N > max(const FloatArrayF< N > &a, const FloatArrayF< N > &b)
std::unique_ptr< EngngModel > InstanciateProblem(DataReader &dr, problemMode mode, int contextFlag, EngngModel *_master, bool parallelFlag)
ClassFactory & classFactory
oofem::oofegGraphicContext gc[OOFEG_LAST_LAYER]
OOFEM_EXPORT const char * PRG_HEADER
The PrintStatistics struct is used to track statistics of the printer.
The PrinterOptions struct is used to configure the Printer class.
LayerHeightModel layerHeightModel
double heatBedTemperature
double depositedMaterialHeatPower
double depositionTemperature
std::array< int, 3 > sizes
std::array< double, 3 > steps
double heatTransferFilmCoefficient
double chamberTemperature
A struct to represent a 3D model.
A struct to represent a single voxel.
std::vector< std::tuple< double, double > > vofHistory
double time_activated()
Get the time the voxel was activated.
std::array< int, 8 > nodes
#define VERBOSE_PRINTS(str, str1)