81 _n_phases(coupledComponents(
"output_phases")),
82 _n_species(coupledComponents(
"output_species")),
86 _n_potentials(coupledComponents(
"output_element_potentials")),
89 "_chemical_composition_action")),
106{
108
110 mooseError(
"Element IDs size does not match number of elements.");
112 _el[i] = &coupledValue(
"elements", i);
113
114 if (isParamValid("output_phases"))
115 {
117 mooseError(
"Phase names vector size does not match number of phases.");
118
120 _ph[i] = &writableVariable(
"output_phases", i);
121 }
122
123 if (isParamValid("output_species"))
124 {
126 mooseError(
"Species name vector size does not match number of output species.");
127
129 _sp[i] = &writableVariable(
"output_species", i);
130 }
131
132 if (isParamValid("output_vapor_pressures"))
133 {
135 mooseError(
"Vapor species name vector size does not match number of output vapor species.");
136
138 _vp[i] = &writableVariable(
"output_vapor_pressures", i);
139 }
140
141 if (isParamValid("output_element_phases"))
142 {
144 mooseError(
"Element phase vector size does not match number of output elements in phases");
145
147 _el_ph[i] = &writableVariable(
"output_element_phases", i);
148 }
149
150 if (isParamValid("output_element_potentials"))
151 {
153 mooseError(
"Element potentials vector size does not match number of element potentials "
154 "specified for output.");
155
157 _el_pot[i] = &writableVariable(
"output_element_potentials", i);
158 }
159
160 const auto dofid_size = std::max( 1, 0);
161 const auto real_size =
165
166
167 auto shared_mem =
168 static_cast<std::byte *>(mmap(nullptr,
169 dofid_size * sizeof(dof_id_type) + real_size * sizeof(Real),
170 PROT_READ | PROT_WRITE,
171 MAP_ANONYMOUS | MAP_SHARED,
172 -1 ,
173 0 ));
174 if (shared_mem == MAP_FAILED)
175 mooseError(
"Failed to allocate shared memory for thermochimica IPC.");
176
177
180
181
182 int sockets[2];
183 if (socketpair(AF_UNIX, SOCK_STREAM, 0, sockets) < 0)
184 mooseError(
"Failed to create socketpair for thermochimica IPC.");
185
186
189 mooseError(
"Fork failed for thermochimica library.");
191 {
192
194
196
197#ifdef THERMOCHIMICA_ENABLED
198
199 if (isParamValid("thermofile"))
200 {
201 const auto thermo_file = this->template getParam<FileName>("thermofile");
202
203 if (thermo_file.length() > 1024)
204 this->paramError("thermofile",
205 "Path exceeds Thermochimica's maximal permissible length of 1024 with ",
206 thermo_file.length(),
207 " characters: ",
208 thermo_file);
209
210 Thermochimica::setThermoFilename(thermo_file);
211
212
213 Thermochimica::parseThermoFile();
214
215 const auto idbg = Thermochimica::checkInfoThermo();
216 if (idbg != 0)
217 this->paramError("thermofile", "Thermochimica data file cannot be parsed. ", idbg);
218 }
219#endif
220
221 while (true)
223 }
224
225
227}
void mooseError(Args &&... args)
void ThermochimicaDataBase_handler(int)
typename std::conditional< is_nodal, NodalUserObject, ElementUserObject >::type ThermochimicaDataBaseParent
The ChemicalCompositionAction sets up user objects, aux kernels, and aux variables for a thermochemis...
const std::vector< std::pair< std::string, std::string > > & phaseElementPairs() const
const std::vector< std::pair< std::string, std::string > > & vaporPhasePairs() const
const std::vector< std::pair< std::string, std::string > > & speciesPhasePairs() const
const std::vector< unsigned int > & elementIDs() const
const std::vector< std::string > & phases() const
const std::vector< std::string > & elementPotentials() const
const std::size_t _n_phases
dof_id_type * _shared_dofid_mem
shared memory pointer for dof_id_type values
const std::vector< std::pair< std::string, std::string > > & _vapor_phase_pairs
const ChemicalCompositionAction & _action
Real * _shared_real_mem
shared memory pointer for Real values
const std::size_t _n_elements
std::vector< MooseWritableVariable * > _vp
Writable vapour pressures for each element.
const std::vector< std::pair< std::string, std::string > > & _phase_element_pairs
OutputMassUnit
Mass unit for output species.
std::vector< MooseWritableVariable * > _el_pot
Writable chemical potential variables for each element.
const std::size_t _n_potentials
const std::size_t _n_vapor_species
std::vector< unsigned int > _el_ids
const bool _output_element_potentials
Element chemical potential output.
const VariableValue & _pressure
const std::size_t _n_species
const std::vector< std::string > & _ph_names
const VariableValue & _temperature
std::vector< const VariableValue * > _el
const std::vector< std::pair< std::string, std::string > > & _species_phase_pairs
const std::size_t _n_phase_elements
const bool _output_element_phases
int _socket
communication socket
std::vector< MooseWritableVariable * > _ph
Writable phase amount variables.
const std::vector< std::string > & _element_potentials
std::vector< MooseWritableVariable * > _sp
Writable species amount variables.
const bool _output_vapor_pressures
std::vector< MooseWritableVariable * > _el_ph
Writable variable for molar amounts of each element in specified phase.
void checkLibraryAvailability(MooseObject &self)
Check if thermochimica is available and throw an error if it is not.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
IntRange< T > make_range(T beg, T end)