21 using namespace miniapps;
23 namespace electromagnetics
26 MagneticDiffusionEOperator::MagneticDiffusionEOperator(
36 std::map<int, double> sigmaAttMap,
37 std::map<int, double> TcapacityAttMap,
38 std::map<int, double> InvTcapAttMap,
39 std::map<int, double> InvTcondAttMap)
42 L2FESpace(L2FES), HCurlFESpace(HCurlFES), HDivFESpace(HDivFES),
43 HGradFESpace(HGradFES),
44 a0(NULL), a1(NULL), a2(NULL), m1(NULL), m2(NULL), m3(NULL),
45 s1(NULL), s2(NULL), grad(NULL), curl(NULL), weakDiv(NULL), weakDivC(NULL),
47 A0(NULL), A1(NULL), A2(NULL), X0(NULL), X1(NULL), X2(NULL), B0(NULL),
48 B1(NULL), B2(NULL), B3(NULL),
50 amg_a0(NULL), pcg_a0(NULL), ads_a2(NULL), pcg_a2(NULL), ams_a1(NULL),
51 pcg_a1(NULL), dsp_m3(NULL),pcg_m3(NULL),
52 dsp_m1(NULL), pcg_m1(NULL), dsp_m2(NULL), pcg_m2(NULL),
53 mu(mu_coef), dt_A1(-1.0), dt_A2(-1.0)
56 for (
int i=0; i<ess_bdr_arg.
Size(); i++)
61 for (
int i=0; i<thermal_ess_bdr_arg.
Size(); i++)
66 for (
int i=0; i<poisson_ess_bdr_arg.
Size(); i++)
103 Vector zero_vec(3); zero_vec = 0.0;
122 true_offset[1] = true_offset[0] + Vsize_l2;
123 true_offset[2] = true_offset[1] + Vsize_rt;
124 true_offset[3] = true_offset[2] + Vsize_h1;
125 true_offset[4] = true_offset[3] + Vsize_nd;
126 true_offset[5] = true_offset[4] + Vsize_rt;
127 true_offset[6] = true_offset[5] + Vsize_l2;
181 true_offset[1] = true_offset[0] + Vsize_l2;
182 true_offset[2] = true_offset[1] + Vsize_rt;
183 true_offset[3] = true_offset[2] + Vsize_h1;
184 true_offset[4] = true_offset[3] + Vsize_nd;
185 true_offset[5] = true_offset[4] + Vsize_rt;
186 true_offset[6] = true_offset[5] + Vsize_l2;
226 for (
int i = 0; i < my_ess_dof_list.
Size(); i++)
228 int dof = my_ess_dof_list[i];
229 if (dof < 0) { dof = -1 - dof; }
230 Phi_gf[i] = homer[i];
325 Vector zero_vec(3); zero_vec = 0.0;
415 if (
A2 == NULL || fabs(dt-
dt_A2) > 1.0e-12*dt )
419 if (
A1 == NULL || fabs(dt-
dt_A1) > 1.0e-12*dt )
441 true_offset[1] = true_offset[0] + Vsize_l2;
442 true_offset[2] = true_offset[1] + Vsize_rt;
443 true_offset[3] = true_offset[2] + Vsize_h1;
444 true_offset[4] = true_offset[3] + Vsize_nd;
445 true_offset[5] = true_offset[4] + Vsize_rt;
446 true_offset[6] = true_offset[5] + Vsize_l2;
482 for (
int i = 0; i < my_ess_dof_list.
Size(); i++)
484 int dof = my_ess_dof_list[i];
485 if (dof < 0) { dof = -1 - dof; }
486 Phi_gf[i] = homer[i];
589 Vector zero_vec(3); zero_vec = 0.0;
666 if (
a0 != NULL ) {
delete a0; }
685 if (
a1 != NULL ) {
delete a1; }
707 if (
a2 != NULL ) {
delete a2; }
723 if (
m1 != NULL ) {
delete m1; }
734 if (
m2 != NULL ) {
delete m2; }
746 if (
m3 != NULL ) {
delete m3; }
758 if (
s1 != NULL ) {
delete s1; }
768 if (
s2 != NULL ) {
delete s2; }
778 if (
curl != NULL ) {
delete curl; }
811 if (
grad != NULL ) {
delete grad; }
825 MPI_Allreduce(&el, &global_el, 1, MPI_DOUBLE, MPI_SUM,
859 if (
curl != NULL ) {
delete curl; }
863 if (
grad != NULL ) {
delete grad; }
865 if (
a0 != NULL ) {
delete a0; }
866 if (
a1 != NULL ) {
delete a1; }
867 if (
a2 != NULL ) {
delete a2; }
868 if (
m1 != NULL ) {
delete m1; }
869 if (
m2 != NULL ) {
delete m2; }
870 if (
s1 != NULL ) {
delete s1; }
871 if (
s2 != NULL ) {
delete s2; }
873 if (
A0 != NULL ) {
delete A0; }
874 if (
X0 != NULL ) {
delete X0; }
875 if (
B0 != NULL ) {
delete B0; }
877 if (
A1 != NULL ) {
delete A1; }
878 if (
X1 != NULL ) {
delete X1; }
879 if (
B1 != NULL ) {
delete B1; }
881 if (
A2 != NULL ) {
delete A2; }
882 if (
X2 != NULL ) {
delete X2; }
883 if (
B2 != NULL ) {
delete B2; }
885 if (
v1 != NULL ) {
delete v1; }
886 if (
v2 != NULL ) {
delete v2; }
897 hypre_ParCSRMatrixPrint(*
A1,
"A1_");
905 hypre_ParCSRMatrixPrint(*
A2,
"A2_");
919 thisSigma = sigma.
Eval(T, ip);
920 return thisSigma*(E*E);
924 const std::map<int, double> &inputMap,
double scale)
928 materialMap =
new std::map<int, double>(inputMap);
937 materialMap =
new std::map<int, double>(*(cloneMe.materialMap));
938 scaleFactor = cloneMe.scaleFactor;
945 std::map<int, double>::iterator it;
948 it = materialMap->find(thisAtt);
949 if (it != materialMap->end())
956 std::cerr <<
"MeshDependentCoefficient attribute " << thisAtt
957 <<
" not found" << std::endl;
961 return value*scaleFactor;
978 #endif // MFEM_USE_MPI
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)
ParFiniteElementSpace & L2FESpace
void buildDiv(MeshDependentCoefficient &InvTcap)
virtual double GetTime() const
Read the currently set time.
int Size() const
Logical size of the array.
Class for domain integration L(v) := (f, v)
virtual void GetEssentialTrueDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_tdof_list, int component=-1)
MPI_Comm GetComm() const
MPI communicator.
void buildM2(MeshDependentCoefficient &alpha)
The Auxiliary-space Maxwell Solver in hypre.
Class for grid function - Vector with associated FE space.
The Auxiliary-space Divergence Solver in hypre.
virtual void GetEssentialVDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_dofs, int component=-1) const
Determine the boundary degrees of freedom.
Subclass constant coefficient.
virtual ~MagneticDiffusionEOperator()
HYPRE_Int N() const
Returns the global number of columns.
MeshDependentCoefficient * InvTcap
void GetVectorValue(int i, const IntegrationPoint &ip, Vector &val) const
HYPRE_Int * ColPart()
Returns the column partitioning.
ParFiniteElementSpace & HDivFESpace
Integrator for (curl u, curl v) for Nedelec elements.
Base abstract class for time dependent operators.
Coefficient defined by a GridFunction. This coefficient is mesh dependent.
void buildS1(double muInv)
virtual void ImplicitSolve(const double dt, const Vector &x, Vector &k)
Solve the equation: k = f(x + dt k, t), for the unknown k at the current time t.
Abstract parallel finite element space.
virtual void ProjectCoefficient(Coefficient &coeff)
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)
(Q div u, div v) for RT elements
void SetPrintLevel(int print_lvl)
void AddDomainInterpolator(DiscreteInterpolator *di)
void Debug(const char *basefilename, double time)
void GetJouleHeating(ParGridFunction &E_gf, ParGridFunction &w_gf) const
void Print(const char *fname) const
Prints the locally owned rows in parallel.
virtual void MakeRef(FiniteElementSpace *f, double *v)
Make the ParGridFunction reference external data on a new FiniteElementSpace.
void buildA1(double muInv, MeshDependentCoefficient &sigma, double dt)
ScaledGFCoefficient(GridFunction *gf, MeshDependentCoefficient &input_mdc)
double p_bc(const Vector &x, double t)
The BoomerAMG solver in hypre.
ParFiniteElementSpace & HCurlFESpace
void ProjectBdrCoefficientNormal(VectorCoefficient &vcoeff, Array< int > &bdr_attr)
void buildS2(MeshDependentCoefficient &alpha)
ParDiscreteLinearOperator * curl
Array< int > thermal_ess_bdr
void buildM3(MeshDependentCoefficient &Tcap)
void SetScaleFactor(const double &scale)
Jacobi preconditioner in hypre.
void buildM1(MeshDependentCoefficient &sigma)
ParMixedBilinearForm * weakDivC
MeshDependentCoefficient * Tcapacity
void SetMaxIter(int max_iter)
Wrapper for hypre's parallel vector class.
ParDiscreteLinearOperator * grad
double ElectricLosses(ParGridFunction &E_gf) const
MeshDependentCoefficient(const std::map< int, double > &inputMap, double scale=1.0)
Base class Coefficient that may optionally depend on time.
void mfem_error(const char *msg)
void SetSize(int nsize)
Change logical size of the array, keep existing entries.
void buildA2(MeshDependentCoefficient &InvTcond, MeshDependentCoefficient &InvTcap, double dt)
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)
MeshDependentCoefficient * sigma
Array< int > poisson_ess_bdr
Class for integration point with weight.
ParFiniteElementSpace & HGradFESpace
void SetPreconditioner(HypreSolver &precond)
Set the hypre solver to be used as a preconditioner.
void ProjectBdrCoefficientTangent(VectorCoefficient &vcoeff, Array< int > &bdr_attr)
ParMixedBilinearForm * weakCurl
MeshDependentCoefficient * InvTcond
void edot_bc(const Vector &x, Vector &E)
class for C-function coefficient
Class for parallel grid function.
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)
Wrapper for hypre's ParCSR matrix class.
virtual void Assemble(int skip_zeros=1)
virtual void Mult(const HypreParVector &b, HypreParVector &x) const
Solve Ax=b with hypre's PCG.
void buildCurl(double muInv)
void buildA0(MeshDependentCoefficient &sigma)
virtual void Mult(const Vector &vx, Vector &dvx_dt) const
Perform the action of the operator: y = k = f(x, t), where k solves the algebraic equation F(x...
ParMixedBilinearForm * weakDiv
Integrator for (Q u, v) for VectorFiniteElements.
void SetTime(const double _t)
Set the current time.