NEMoSys  0.63.0
A modular, extensible resource with robust automated mesh generation, mesh quality analysis, adaptive mesh refinement, and data transfer between arbitrary meshes.
NEM::DRV::FoamRefineDriver Class Reference

Detailed Description

Definition at line 58 of file FoamRefineDriver.H.

Classes

struct  Opts
 

Public Types

using Files = DriverInOutFiles
 

Public Member Functions

 FoamRefineDriver (Files files, Opts opts)
 
const OptsgetOpts () const
 
void setOpts (Opts opts)
 
void execute () const override
 Run the workflow represented by the driver. More...
 
virtual const FilesgetFiles () const
 
virtual void setFiles (Files files)
 

Static Public Member Functions

static std::unique_ptr< NemDriverreadJSON (const jsoncons::json &inputjson)
 Factory method for all drivers. More...
 

Protected Attributes

Files files_
 

Private Member Functions

 FoamRefineDriver ()
 

Private Attributes

Opts opts_
 

Inherits NEM::DRV::RefineDriver.

Member Typedef Documentation

◆ Files

Definition at line 42 of file RefineDriver.H.

Constructor & Destructor Documentation

◆ FoamRefineDriver() [1/2]

NEM::DRV::FoamRefineDriver::FoamRefineDriver ( Files  files,
Opts  opts 
)

Definition at line 99 of file FoamRefineDriver.C.

100  : RefineDriver(std::move(files)), opts_(std::move(opts)) {}
RefineDriver(Files files)
Definition: RefineDriver.C:34

◆ FoamRefineDriver() [2/2]

NEM::DRV::FoamRefineDriver::FoamRefineDriver ( )
private

Definition at line 102 of file FoamRefineDriver.C.

102 : FoamRefineDriver({{}, {}}, {{}, {}}) {}

Member Function Documentation

◆ execute()

void NEM::DRV::FoamRefineDriver::execute ( ) const
overridevirtual

Implements NEM::DRV::NemDriver.

Definition at line 110 of file FoamRefineDriver.C.

References Foam::AMRFoam::assignToVolScalarField(), meshBase::CreateShared(), NEM::DRV::FoamRefineOptsBase::endTime, NEM::DRV::RefineDriver::files_, NEM::DRV::FoamRefineDriver::Opts::inputFieldFile, NEM::DRV::DriverInOutFiles::inputMeshFile, mesh, opts_, NEM::DRV::DriverInOutFiles::outputMeshFile, NEM::DRV::FoamRefineDriver::Opts::refCriteria, NEM::DRV::RefineDriver::RefineDriver(), NEM::DRV::FoamRefineOptsBase::refineInterval, NEM::DRV::FoamRefineOptsBase::startTime, NEM::DRV::FoamRefineOptsBase::timeStep, Foam::AMRFoam::updateAMRML(), and NEM::DRV::FoamRefineDriver::Opts::VALUE.

110  {
111  // Initializes AMR workflow
112  std::unique_ptr<getDicts> initFoam;
113  initFoam = std::unique_ptr<getDicts>(new getDicts());
114  initFoam->writeBasicDicts("system/", this->opts_.startTime,
115  this->opts_.timeStep, this->opts_.endTime);
116  initFoam->createDynamicMeshDict(true);
117  auto controlDict_ = initFoam->createControlDict(true);
118  Foam::Time runTime(controlDict_.get(), ".", ".");
119 
120  auto amr = initializeRefine(this->files_, this->opts_, runTime);
121 
122  int nSteps = static_cast<int>(std::round(opts_.endTime / opts_.timeStep));
123 
124  // Creates scalar field from incoming text/CSV files
125  Foam::volScalarField meshFieldXY =
126  amr->readIncomingCellField(this->opts_.inputFieldFile, "meshFieldXY");
127 
129  for (int i = 0; i < nSteps; i++) {
130  amr->updateAMR(this->opts_.refineInterval, this->opts_.maxRefinement,
131  meshFieldXY, this->opts_.lowerRefineLevel,
132  this->opts_.upperRefineLevel, this->opts_.unrefineAbove,
133  this->opts_.unrefineBelow, this->opts_.nBufferLayers,
134  this->opts_.maxCells);
135 
136  runTime++;
137  }
138  meshFieldXY.write();
139  } else { // opts_.refCriteria == Opts::Criteria::GRADIENT
140  Foam::volScalarField magGrad = amr->getGradient(meshFieldXY);
141  for (int i = 0; i < nSteps; i++) {
142  amr->updateAMR(this->opts_.refineInterval, this->opts_.maxRefinement,
143  magGrad, this->opts_.lowerRefineLevel,
144  this->opts_.upperRefineLevel, this->opts_.unrefineAbove,
145  this->opts_.unrefineBelow, this->opts_.nBufferLayers,
146  this->opts_.maxCells);
147 
148  runTime++;
149  }
150  magGrad.write();
151  }
152 
153  finishRefine(amr.get(), this->files_.outputMeshFile, runTime);
154 
155  std::cout << "End!" << std::endl;
156 }
std::string outputMeshFile
Definition: NemDriver.H:91

◆ getFiles()

const RefineDriver::Files & NEM::DRV::RefineDriver::getFiles ( ) const
virtualinherited

Definition at line 40 of file RefineDriver.C.

References NEM::DRV::RefineDriver::files_.

40  {
41  return files_;
42 }

◆ getOpts()

const FoamRefineDriver::Opts & NEM::DRV::FoamRefineDriver::getOpts ( ) const

Definition at line 104 of file FoamRefineDriver.C.

References opts_.

104  {
105  return opts_;
106 }

◆ readJSON()

std::unique_ptr< NemDriver > NEM::DRV::NemDriver::readJSON ( const jsoncons::json &  inputjson)
staticinherited
Parameters
inputjsonjson input with "Program Type" key
Returns
pointer to base NemDriver class

Definition at line 37 of file NemDriver.C.

Referenced by NEM::DRV::MeshGenDriver::MeshGenDriver().

37  {
38  return inputjson.as<std::unique_ptr<NemDriver>>();
39 }

◆ setFiles()

void NEM::DRV::RefineDriver::setFiles ( Files  files)
virtualinherited

Definition at line 44 of file RefineDriver.C.

References NEM::DRV::RefineDriver::files_.

44  {
45  this->files_ = std::move(files);
46 }

◆ setOpts()

void NEM::DRV::FoamRefineDriver::setOpts ( Opts  opts)

Definition at line 108 of file FoamRefineDriver.C.

References opts_.

108 { this->opts_ = std::move(opts); }

Member Data Documentation

◆ files_

◆ opts_

Opts NEM::DRV::FoamRefineDriver::opts_
private

Definition at line 86 of file FoamRefineDriver.H.

Referenced by execute(), getOpts(), and setOpts().


The documentation for this class was generated from the following files: