Generate And View A Coarse Mesh

This tutorial uses geo and a JCMT pattern to select a layout file, stages the generated grid in a separate directory, and opens the grid in JCMview.

Run the tutorial from the tutorial root:

python core/geo_view/02_coarse/run.py

Python File

import jcmsuite

# Instead of using the default we use the layout file called layout.coarse.jcm.
# Additionally, we stage the grid file in a subdirectory called grid_coarse.
jcmsuite.geo(
    project_dir="jcm",
    jcmt_pattern="coarse",
    working_dir="grid_coarse",
)

# Display the grid file
jcmsuite.view("jcm/grid_coarse/grid.jcm")

Project Files

jcm/layout.jcm
Layout2D {
  UnitOfLength = 1e-6

  MeshOptions {
    MaximumSideLength = 1
  }

  Objects {
    Parallelogram {
      Name = "ComputationalDomain"
      DomainId = 1
      Priority = ComputationalDomain
      Width = 4
      Height = 4

      Boundary {
        Class = Transparent
      }
    }

    Circle {
      Name = "Rod"
      DomainId = 2
      Priority = 1
      Radius = 0.5
      RefineAll = 4
    }
  }
}
jcm/layout.coarse.jcm
Layout2D {
  UnitOfLength = 1e-6

  MeshOptions {
    MaximumSideLength = 1
  }

  Objects {
    # Computational domain
    Parallelogram {
      Name = "ComputationalDomain"
      DomainId = 1
      Priority = ComputationalDomain
      Width = 4
      Height = 4

      Boundary {
        Class = Transparent
      }
    }

    # Scatterer (rod)
    Circle {
      Name = "Rod"
      DomainId = 2
      Priority = 1
      Radius = 0.5
      RefineAll = 4
    }
  }
}
jcm/materials.jcm
# material properties for the surroundings (air)
Material {
  DomainId = 1
  RelPermittivity = 1.0
  RelPermeability = 1.0
}

# material properties the glass rod
Material {
  DomainId = 2
  RelPermittivity = 2.3104 # 1.52^2
  RelPermeability = 1.0
}
jcm/mie2D.jcmp
Project {
  InfoLevel = 3
  Electromagnetics {
    TimeHarmonic {
      Scattering {
        FieldComponents = Electric
        Accuracy {
          FiniteElementDegree = 3
          Refinement {
            MaxNumberSteps = 0
            PreRefinements = 0
          }
        }
      }
    }
  }
}
jcm/sources.jcm
SourceBag {
  Source {
    ElectricFieldStrength {
      PlaneWave {
        K = [1.14239732857811e7 0.0 0.0]
        Amplitude = [0 0 1]
      }
    }
  }
}