Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maxwell solver example #90

Merged
merged 13 commits into from
Nov 29, 2023
Merged
22 changes: 17 additions & 5 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ make solvers
Builds each solver executable.
make {solver}
Builds a solver executable,
solver can be acoustics/advection/bns/cns/elliptic/fokkerPlanck/gradient/ins.
solver can be acoustics/advection/bns/cns/elliptic/fokkerPlanck/gradient/ins/maxwell.
make clean
Cleans all solver executables, libraries, and object files.
make clean-{solver}
Expand All @@ -64,7 +64,7 @@ Can use "make verbose=true" for verbose output.
endef

ifeq (,$(filter solvers \
acoustics advection bns cns elliptic fokkerPlanck gradient ins \
acoustics advection bns cns elliptic fokkerPlanck gradient ins maxwell \
lib clean clean-kernels \
realclean info help test,$(MAKECMDGOALS)))
ifneq (,$(MAKECMDGOALS))
Expand All @@ -88,12 +88,12 @@ LIBP_CORE_LIBS=timeStepper linearSolver parAlmond mesh ogs linAlg core
SOLVER_DIR =${LIBP_DIR}/solvers

.PHONY: all solvers libp_libs \
acoustics advection bns lbs cns elliptic fokkerPlanck gradient ins \
acoustics advection bns lbs cns elliptic fokkerPlanck gradient ins maxwell\
clean clean-libs realclean help info

all: solvers

solvers: acoustics advection bns lbs cns elliptic fokkerPlanck gradient ins
solvers: acoustics advection bns lbs cns elliptic fokkerPlanck gradient ins maxwell

libp_libs:
ifneq (,${verbose})
Expand Down Expand Up @@ -174,10 +174,19 @@ else
@${MAKE} -C ${SOLVER_DIR}/$(@F) --no-print-directory
endif

maxwell: libp_libs
ifneq (,${verbose})
${MAKE} -C ${SOLVER_DIR}/$(@F) verbose=${verbose}
else
@printf "%b" "$(SOL_COLOR)Building $(@F) solver$(NO_COLOR)\n";
@${MAKE} -C ${SOLVER_DIR}/$(@F) --no-print-directory
endif


#cleanup
clean: clean-acoustics clean-advection clean-bns clean-lbs clean-cns \
clean-elliptic clean-fokkerPlanck clean-gradient clean-ins \
clean-libs
clean-maxwell clean-libs

clean-acoustics:
${MAKE} -C ${SOLVER_DIR}/acoustics clean
Expand Down Expand Up @@ -206,6 +215,9 @@ clean-gradient:
clean-ins:
${MAKE} -C ${SOLVER_DIR}/ins clean

clean-maxwell:
${MAKE} -C ${SOLVER_DIR}/maxwell clean

clean-libs:
${MAKE} -C ${LIBP_LIBS_DIR} clean

Expand Down
45 changes: 45 additions & 0 deletions solvers/maxwell/data/maxwellGaussian2D.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*

The MIT License (MIT)

Copyright (c) 2017-2022 Tim Warburton, Noel Chalmers, Jesse Chan, Ali Karakus

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

*/


// Boundary conditions
/* PEC 1 */
#define maxwellDirichletConditions2D(bc, t, x, y, nx, ny, HxM, HyM, EzM, HxB, HyB, EzB) \
{ \
if(bc==1){ \
*(HxB) = HxM; \
*(HyB) = HyM; \
*(EzB) = -EzM; \
} \
}

// Initial conditions
#define maxwellInitialConditions2D(t, x, y, Hx, Hy, Ez) \
{ \
*(Hx) = 0.0; \
*(Hy) = 0.0; \
*(Ez) = exp(-3*(x*x+y*y)); \
}
52 changes: 52 additions & 0 deletions solvers/maxwell/data/maxwellGaussian3D.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*

The MIT License (MIT)

Copyright (c) 2017-2022 Tim Warburton, Noel Chalmers, Jesse Chan, Ali Karakus

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

*/



// Boundary conditions
/* PEC=1 */
#define maxwellDirichletConditions3D(bc, t, x, y, z, nx, ny, nz, HxM, HyM, HzM, ExM, EyM, EzM, HxB, HyB, HzB, ExB, EyB, EzB) \
{ \
if(bc==1){ \
*(HxB) = HxM; \
*(HyB) = HyM; \
*(HzB) = HzM; \
*(ExB) = -ExM; \
*(EyB) = -EyM; \
*(EzB) = -EzM; \
} \
}

// Initial conditions
#define maxwellInitialConditions3D(t, x, y, z, Hx, Hy, Hz, Ex, Ey, Ez) \
{ \
*(Hx) = 0.0; \
*(Hy) = 0.0; \
*(Hz) = 0.0; \
*(Ex) = 0.0; \
*(Ey) = 0.0; \
*(Ez) = exp(-3*(x*x+y*y+z*z)); \
}
48 changes: 48 additions & 0 deletions solvers/maxwell/data/maxwellMode2D.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*

The MIT License (MIT)

Copyright (c) 2017-2022 Tim Warburton, Noel Chalmers, Jesse Chan, Ali Karakus

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

*/



// Boundary conditions
/* PEC=1 */
#define maxwellDirichletConditions2D(bc, t, x, y, nx, ny, HxM, HyM, EzM, HxB, HyB, EzB) \
{ \
if(bc==1){ \
*(HxB) = HxM; \
*(HyB) = HyM; \
*(EzB) = -EzM; \
} \
}

// Initial conditions
#define maxwellInitialConditions2D(t, x, y, Hx, Hy, Ez) \
{ \
dfloat n = 1., m = 2.; \
dfloat omega = M_PI*sqrt(n*n+m*m); \
*(Hx) = -M_PI*n*sin(m*M_PI*x)*cos(n*M_PI*y)*sin(omega*t)/omega; \
*(Hy) = M_PI*m*cos(m*M_PI*x)*sin(n*M_PI*y)*sin(omega*t)/omega; \
*(Ez) = sin(m*M_PI*x)*sin(n*M_PI*y)*cos(omega*t); \
}
54 changes: 54 additions & 0 deletions solvers/maxwell/data/maxwellMode3D.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*

The MIT License (MIT)

Copyright (c) 2017-2022 Tim Warburton, Noel Chalmers, Jesse Chan, Ali Karakus

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

*/



// Boundary conditions
/* PEC=1 */
#define maxwellDirichletConditions3D(bc, t, x, y, z, nx, ny, nz, HxM, HyM, HzM, ExM, EyM, EzM, HxB, HyB, HzB, ExB, EyB, EzB) \
{ \
if(bc==1){ \
*(HxB) = HxM; \
*(HyB) = HyM; \
*(HzB) = HzM; \
*(ExB) = -ExM; \
*(EyB) = -EyM; \
*(EzB) = -EzM; \
} \
}

// Initial conditions
#define maxwellInitialConditions3D(t, x, y, z, Hx, Hy, Hz, Ex, Ey, Ez) \
{ \
dfloat n = 1., m = 2.; \
const dfloat omega = M_PI*sqrt(n*n+m*m); \
*(Hx) = -M_PI*n*sin(m*M_PI*x)*cos(n*M_PI*y)*sin(omega*t)/omega; \
*(Hy) = M_PI*m*cos(m*M_PI*x)*sin(n*M_PI*y)*sin(omega*t)/omega; \
*(Hz) = 0; \
*(Ex) = 0; \
*(Ey) = 0; \
*(Ez) = sin(m*M_PI*x)*sin(n*M_PI*y)*cos(omega*t); \
}
Loading
Loading