Lines Matching refs:sw
184 static PetscErrorCode CreateSwarm(DM dm, AppCtx *user, DM *sw) in CreateSwarm() argument
191 PetscCall(DMCreate(PetscObjectComm((PetscObject)dm), sw)); in CreateSwarm()
192 PetscCall(DMSetType(*sw, DMSWARM)); in CreateSwarm()
193 PetscCall(DMSetDimension(*sw, dim)); in CreateSwarm()
194 PetscCall(DMSwarmSetType(*sw, DMSWARM_PIC)); in CreateSwarm()
195 PetscCall(DMSwarmSetCellDM(*sw, dm)); in CreateSwarm()
196 PetscCall(DMSwarmRegisterPetscDatatypeField(*sw, "w_q", 1, PETSC_SCALAR)); in CreateSwarm()
197 PetscCall(DMSwarmRegisterPetscDatatypeField(*sw, "velocity", dim, PETSC_REAL)); in CreateSwarm()
198 PetscCall(DMSwarmRegisterPetscDatatypeField(*sw, "species", 1, PETSC_INT)); in CreateSwarm()
199 PetscCall(DMSwarmRegisterPetscDatatypeField(*sw, "initCoordinates", dim, PETSC_REAL)); in CreateSwarm()
200 PetscCall(DMSwarmRegisterPetscDatatypeField(*sw, "initVelocity", dim, PETSC_REAL)); in CreateSwarm()
201 PetscCall(DMSwarmRegisterPetscDatatypeField(*sw, "E_field", dim, PETSC_REAL)); in CreateSwarm()
202 PetscCall(DMSwarmFinalizeFieldRegister(*sw)); in CreateSwarm()
203 PetscCall(DMSwarmComputeLocalSizeFromOptions(*sw)); in CreateSwarm()
204 PetscCall(DMSwarmInitializeCoordinates(*sw)); in CreateSwarm()
205 PetscCall(DMSwarmInitializeVelocitiesFromOptions(*sw, v0)); in CreateSwarm()
206 PetscCall(DMSetFromOptions(*sw)); in CreateSwarm()
207 PetscCall(DMSetApplicationContext(*sw, user)); in CreateSwarm()
208 PetscCall(PetscObjectSetName((PetscObject)*sw, "Particles")); in CreateSwarm()
209 PetscCall(DMViewFromOptions(*sw, NULL, "-sw_view")); in CreateSwarm()
213 PetscCall(DMSwarmCreateGlobalVectorFromField(*sw, DMSwarmPICField_coor, &gc)); in CreateSwarm()
214 PetscCall(DMSwarmCreateGlobalVectorFromField(*sw, "initCoordinates", &gc0)); in CreateSwarm()
216 PetscCall(DMSwarmDestroyGlobalVectorFromField(*sw, DMSwarmPICField_coor, &gc)); in CreateSwarm()
217 PetscCall(DMSwarmDestroyGlobalVectorFromField(*sw, "initCoordinates", &gc0)); in CreateSwarm()
218 PetscCall(DMSwarmCreateGlobalVectorFromField(*sw, "velocity", &gv)); in CreateSwarm()
219 PetscCall(DMSwarmCreateGlobalVectorFromField(*sw, "initVelocity", &gv0)); in CreateSwarm()
221 PetscCall(DMSwarmDestroyGlobalVectorFromField(*sw, "velocity", &gv)); in CreateSwarm()
222 PetscCall(DMSwarmDestroyGlobalVectorFromField(*sw, "initVelocity", &gv0)); in CreateSwarm()
227 PetscCall(DMSwarmVectorDefineFields(*sw, 2, fieldnames)); in CreateSwarm()
232 static PetscErrorCode ComputeFieldAtParticles_Coulomb(SNES snes, DM sw, PetscReal E[]) in ComputeFieldAtParticles_Coulomb() argument
241 PetscCall(DMGetDimension(sw, &dim)); in ComputeFieldAtParticles_Coulomb()
242 PetscCall(DMSwarmGetLocalSize(sw, &Np)); in ComputeFieldAtParticles_Coulomb()
244 PetscCall(DMSwarmGetField(sw, DMSwarmPICField_coor, NULL, NULL, (void **)&coords)); in ComputeFieldAtParticles_Coulomb()
259 PetscCall(DMSwarmRestoreField(sw, DMSwarmPICField_coor, NULL, NULL, (void **)&coords)); in ComputeFieldAtParticles_Coulomb()
263 static PetscErrorCode ComputeFieldAtParticles_Primal(SNES snes, DM sw, PetscReal E[]) in ComputeFieldAtParticles_Primal() argument
277 PetscCall(DMGetDimension(sw, &dim)); in ComputeFieldAtParticles_Primal()
278 PetscCall(DMSwarmGetLocalSize(sw, &Np)); in ComputeFieldAtParticles_Primal()
281 PetscCall(DMSwarmVectorGetField(sw, &Nf, &tmp)); in ComputeFieldAtParticles_Primal()
284 PetscCall(DMSwarmVectorDefineField(sw, "w_q")); in ComputeFieldAtParticles_Primal()
285 PetscCall(DMCreateMassMatrix(sw, dm, &M_p)); in ComputeFieldAtParticles_Primal()
286 PetscCall(DMSwarmVectorDefineFields(sw, Nf, oldFields)); in ComputeFieldAtParticles_Primal()
293 PetscCall(DMSwarmCreateGlobalVectorFromField(sw, "w_q", &f)); in ComputeFieldAtParticles_Primal()
298 PetscCall(DMSwarmDestroyGlobalVectorFromField(sw, "w_q", &f)); in ComputeFieldAtParticles_Primal()
310 …PetscCheck(PetscAbsScalar(sum) < chargeTol, PetscObjectComm((PetscObject)sw), PETSC_ERR_PLIB, "Cha… in ComputeFieldAtParticles_Primal()
330 PetscCall(DMSwarmSortGetAccess(sw)); in ComputeFieldAtParticles_Primal()
332 PetscCall(DMSwarmGetField(sw, DMSwarmPICField_coor, NULL, NULL, (void **)&coords)); in ComputeFieldAtParticles_Primal()
341 PetscCall(DMSwarmSortGetPointsPerCell(sw, c, &Ncp, &points)); in ComputeFieldAtParticles_Primal()
362 PetscCall(DMSwarmSortRestorePointsPerCell(sw, c, &Ncp, &points)); in ComputeFieldAtParticles_Primal()
364 PetscCall(DMSwarmRestoreField(sw, DMSwarmPICField_coor, NULL, NULL, (void **)&coords)); in ComputeFieldAtParticles_Primal()
365 PetscCall(DMSwarmSortRestoreAccess(sw)); in ComputeFieldAtParticles_Primal()
370 static PetscErrorCode ComputeFieldAtParticles_Mixed(SNES snes, DM sw, PetscReal E[]) in ComputeFieldAtParticles_Mixed() argument
387 PetscCall(DMGetDimension(sw, &dim)); in ComputeFieldAtParticles_Mixed()
388 PetscCall(DMSwarmGetLocalSize(sw, &Np)); in ComputeFieldAtParticles_Mixed()
396 PetscCall(DMSwarmVectorGetField(sw, &Nf, &tmp)); in ComputeFieldAtParticles_Mixed()
399 PetscCall(DMSwarmVectorDefineField(sw, "w_q")); in ComputeFieldAtParticles_Mixed()
400 PetscCall(DMCreateMassMatrix(sw, potential_dm, &M_p)); in ComputeFieldAtParticles_Mixed()
401 PetscCall(DMSwarmVectorDefineFields(sw, Nf, oldFields)); in ComputeFieldAtParticles_Mixed()
407 PetscCall(DMSwarmCreateGlobalVectorFromField(sw, "w_q", &f)); in ComputeFieldAtParticles_Mixed()
411 PetscCall(DMSwarmDestroyGlobalVectorFromField(sw, "w_q", &f)); in ComputeFieldAtParticles_Mixed()
429 …PetscCheck(PetscAbsScalar(sum) < chargeTol, PetscObjectComm((PetscObject)sw), PETSC_ERR_PLIB, "Cha… in ComputeFieldAtParticles_Mixed()
447 PetscCall(DMSwarmSortGetAccess(sw)); in ComputeFieldAtParticles_Mixed()
449 PetscCall(DMSwarmGetField(sw, DMSwarmPICField_coor, NULL, NULL, (void **)&coords)); in ComputeFieldAtParticles_Mixed()
458 PetscCall(DMSwarmSortGetPointsPerCell(sw, c, &Ncp, &points)); in ComputeFieldAtParticles_Mixed()
480 PetscCall(DMSwarmSortRestorePointsPerCell(sw, c, &Ncp, &points)); in ComputeFieldAtParticles_Mixed()
482 PetscCall(DMSwarmRestoreField(sw, DMSwarmPICField_coor, NULL, NULL, (void **)&coords)); in ComputeFieldAtParticles_Mixed()
483 PetscCall(DMSwarmSortRestoreAccess(sw)); in ComputeFieldAtParticles_Mixed()
488 static PetscErrorCode ComputeFieldAtParticles(SNES snes, DM sw, PetscReal E[]) in ComputeFieldAtParticles() argument
495 PetscValidHeaderSpecific(sw, DM_CLASSID, 2); in ComputeFieldAtParticles()
497 PetscCall(DMGetDimension(sw, &dim)); in ComputeFieldAtParticles()
498 PetscCall(DMSwarmGetLocalSize(sw, &Np)); in ComputeFieldAtParticles()
499 PetscCall(DMGetApplicationContext(sw, &ctx)); in ComputeFieldAtParticles()
504 PetscCall(ComputeFieldAtParticles_Primal(snes, sw, E)); in ComputeFieldAtParticles()
507 PetscCall(ComputeFieldAtParticles_Coulomb(snes, sw, E)); in ComputeFieldAtParticles()
510 PetscCall(ComputeFieldAtParticles_Mixed(snes, sw, E)); in ComputeFieldAtParticles()
522 DM sw; in RHSFunction() local
531 PetscCall(TSGetDM(ts, &sw)); in RHSFunction()
532 PetscCall(DMGetDimension(sw, &dim)); in RHSFunction()
533 PetscCall(DMSwarmGetField(sw, "initCoordinates", NULL, NULL, (void **)&coords)); in RHSFunction()
534 PetscCall(DMSwarmGetField(sw, "initVelocity", NULL, NULL, (void **)&vel)); in RHSFunction()
535 PetscCall(DMSwarmGetField(sw, "E_field", NULL, NULL, (void **)&E)); in RHSFunction()
540 PetscCall(ComputeFieldAtParticles(snes, sw, E)); in RHSFunction()
553 PetscCall(DMSwarmRestoreField(sw, "initCoordinates", NULL, NULL, (void **)&coords)); in RHSFunction()
554 PetscCall(DMSwarmRestoreField(sw, "initVelocity", NULL, NULL, (void **)&vel)); in RHSFunction()
555 PetscCall(DMSwarmRestoreField(sw, "E_field", NULL, NULL, (void **)&E)); in RHSFunction()
569 DM sw; in RHSJacobian() local
574 PetscCall(TSGetDM(ts, &sw)); in RHSJacobian()
575 PetscCall(DMGetDimension(sw, &dim)); in RHSJacobian()
578 PetscCall(DMSwarmGetField(sw, "initCoordinates", NULL, NULL, (void **)&coords)); in RHSJacobian()
579 PetscCall(DMSwarmGetField(sw, "initVelocity", NULL, NULL, (void **)&vel)); in RHSJacobian()
592 PetscCall(DMSwarmRestoreField(sw, "initCoordinates", NULL, NULL, (void **)&coords)); in RHSJacobian()
593 PetscCall(DMSwarmRestoreField(sw, "initVelocity", NULL, NULL, (void **)&vel)); in RHSJacobian()
601 DM sw; in RHSFunctionX() local
607 PetscCall(TSGetDM(ts, &sw)); in RHSFunctionX()
608 PetscCall(DMGetDimension(sw, &dim)); in RHSFunctionX()
623 DM sw; in RHSFunctionV() local
632 PetscCall(TSGetDM(ts, &sw)); in RHSFunctionV()
633 PetscCall(DMGetDimension(sw, &dim)); in RHSFunctionV()
634 PetscCall(DMSwarmGetField(sw, "initCoordinates", NULL, NULL, (void **)&coords)); in RHSFunctionV()
635 PetscCall(DMSwarmGetField(sw, "initVelocity", NULL, NULL, (void **)&vel)); in RHSFunctionV()
636 PetscCall(DMSwarmGetField(sw, "E_field", NULL, NULL, (void **)&E)); in RHSFunctionV()
642 PetscCall(ComputeFieldAtParticles(snes, sw, E)); in RHSFunctionV()
654 PetscCall(DMSwarmRestoreField(sw, "initCoordinates", NULL, NULL, (void **)&coords)); in RHSFunctionV()
655 PetscCall(DMSwarmRestoreField(sw, "initVelocity", NULL, NULL, (void **)&vel)); in RHSFunctionV()
656 PetscCall(DMSwarmRestoreField(sw, "E_field", NULL, NULL, (void **)&E)); in RHSFunctionV()
664 DM sw; in RHSJacobianS() local
668 PetscCall(TSGetDM(ts, &sw)); in RHSJacobianS()
669 PetscCall(DMGetDimension(sw, &dim)); in RHSJacobianS()
687 DM dm, sw; in RHSObjectiveF() local
694 PetscCall(TSGetDM(ts, &sw)); in RHSObjectiveF()
695 PetscCall(DMGetDimension(sw, &dim)); in RHSObjectiveF()
705 PetscCall(DMSwarmGetField(sw, "initCoordinates", NULL, NULL, (void **)&coords)); in RHSObjectiveF()
706 PetscCall(DMSwarmGetField(sw, "initVelocity", NULL, NULL, (void **)&vel)); in RHSObjectiveF()
708 PetscCall(DMSwarmSortGetAccess(sw)); in RHSObjectiveF()
716 PetscCall(DMSwarmSortGetPointsPerCell(sw, c, &Ncp, &points)); in RHSObjectiveF()
728 PetscCall(DMSwarmSortRestorePointsPerCell(sw, c, &Ncp, &points)); in RHSObjectiveF()
730 PetscCall(DMSwarmSortRestoreAccess(sw)); in RHSObjectiveF()
731 PetscCall(DMSwarmRestoreField(sw, "initCoordinates", NULL, NULL, (void **)&coords)); in RHSObjectiveF()
732 PetscCall(DMSwarmRestoreField(sw, "initVelocity", NULL, NULL, (void **)&vel)); in RHSObjectiveF()
743 DM sw; in RHSFunctionG() local
752 PetscCall(TSGetDM(ts, &sw)); in RHSFunctionG()
753 PetscCall(DMGetDimension(sw, &dim)); in RHSFunctionG()
754 PetscCall(DMSwarmGetField(sw, "initCoordinates", NULL, NULL, (void **)&coords)); in RHSFunctionG()
755 PetscCall(DMSwarmGetField(sw, "initVelocity", NULL, NULL, (void **)&vel)); in RHSFunctionG()
756 PetscCall(DMSwarmGetField(sw, "E_field", NULL, NULL, (void **)&E)); in RHSFunctionG()
757 PetscCall(DMSwarmGetLocalSize(sw, &Np)); in RHSFunctionG()
764 PetscCall(ComputeFieldAtParticles(snes, sw, E)); in RHSFunctionG()
775 PetscCall(DMSwarmRestoreField(sw, "initCoordinates", NULL, NULL, (void **)&coords)); in RHSFunctionG()
776 PetscCall(DMSwarmRestoreField(sw, "initVelocity", NULL, NULL, (void **)&vel)); in RHSFunctionG()
777 PetscCall(DMSwarmRestoreField(sw, "E_field", NULL, NULL, (void **)&E)); in RHSFunctionG()
785 DM sw; in CreateSolution() local
790 PetscCall(TSGetDM(ts, &sw)); in CreateSolution()
791 PetscCall(DMGetDimension(sw, &dim)); in CreateSolution()
792 PetscCall(DMSwarmGetLocalSize(sw, &Np)); in CreateSolution()
805 DM sw; in SetProblem() local
808 PetscCall(TSGetDM(ts, &sw)); in SetProblem()
809 PetscCall(DMGetApplicationContext(sw, &user)); in SetProblem()
815 PetscCall(DMGetDimension(sw, &dim)); in SetProblem()
816 PetscCall(DMSwarmGetLocalSize(sw, &Np)); in SetProblem()
834 PetscCall(DMGetDimension(sw, &dim)); in SetProblem()
835 PetscCall(DMSwarmGetLocalSize(sw, &Np)); in SetProblem()
916 DM sw; in InitializeSolveAndSwarm() local
922 PetscCall(TSGetDM(ts, &sw)); in InitializeSolveAndSwarm()
923 PetscCall(DMGetApplicationContext(sw, &user)); in InitializeSolveAndSwarm()
927 PetscCall(DMSwarmInitializeCoordinates(sw)); in InitializeSolveAndSwarm()
928 PetscCall(DMSwarmInitializeVelocitiesFromOptions(sw, v0)); in InitializeSolveAndSwarm()
929 PetscCall(DMSwarmMigrate(sw, PETSC_TRUE)); in InitializeSolveAndSwarm()
937 PetscCall(DMSwarmCreateGlobalVectorFromField(sw, DMSwarmPICField_coor, &gc)); in InitializeSolveAndSwarm()
938 PetscCall(DMSwarmCreateGlobalVectorFromField(sw, "initCoordinates", &gc0)); in InitializeSolveAndSwarm()
941 PetscCall(DMSwarmDestroyGlobalVectorFromField(sw, DMSwarmPICField_coor, &gc)); in InitializeSolveAndSwarm()
942 PetscCall(DMSwarmDestroyGlobalVectorFromField(sw, "initCoordinates", &gc0)); in InitializeSolveAndSwarm()
943 PetscCall(DMSwarmCreateGlobalVectorFromField(sw, "velocity", &gv)); in InitializeSolveAndSwarm()
944 PetscCall(DMSwarmCreateGlobalVectorFromField(sw, "initVelocity", &gv0)); in InitializeSolveAndSwarm()
947 PetscCall(DMSwarmDestroyGlobalVectorFromField(sw, "velocity", &gv)); in InitializeSolveAndSwarm()
948 PetscCall(DMSwarmDestroyGlobalVectorFromField(sw, "initVelocity", &gv0)); in InitializeSolveAndSwarm()
963 DM sw; in ComputeError() local
973 PetscCall(TSGetDM(ts, &sw)); in ComputeError()
974 PetscCall(DMGetApplicationContext(sw, &user)); in ComputeError()
975 PetscCall(DMGetDimension(sw, &dim)); in ComputeError()
980 PetscCall(DMSwarmGetField(sw, "initCoordinates", NULL, NULL, (void **)&coords)); in ComputeError()
981 PetscCall(DMSwarmGetField(sw, "initVelocity", NULL, NULL, (void **)&vel)); in ComputeError()
1007 PetscCall(DMSwarmRestoreField(sw, "initCoordinates", NULL, NULL, (void **)&coords)); in ComputeError()
1008 PetscCall(DMSwarmRestoreField(sw, "initVelocity", NULL, NULL, (void **)&vel)); in ComputeError()
1018 DM sw; in EnergyMonitor() local
1026 PetscCall(TSGetDM(ts, &sw)); in EnergyMonitor()
1027 PetscCall(DMGetDimension(sw, &dim)); in EnergyMonitor()
1031 PetscCall(DMSwarmGetField(sw, DMSwarmPICField_coor, NULL, NULL, (void **)&coords)); in EnergyMonitor()
1032 PetscCall(DMSwarmGetField(sw, "E_field", NULL, NULL, (void **)&E)); in EnergyMonitor()
1057 PetscCall(DMSwarmRestoreField(sw, DMSwarmPICField_coor, NULL, NULL, (void **)&coords)); in EnergyMonitor()
1058 PetscCall(DMSwarmRestoreField(sw, "E_field", NULL, NULL, (void **)&E)); in EnergyMonitor()
1067 DM sw; in SetUpMigrateParticles() local
1071 PetscCall(TSGetDM(ts, &sw)); in SetUpMigrateParticles()
1072 PetscCall(DMViewFromOptions(sw, NULL, "-migrate_view_pre")); in SetUpMigrateParticles()
1080 PetscCall(DMSwarmCreateGlobalVectorFromField(sw, DMSwarmPICField_coor, &gc)); in SetUpMigrateParticles()
1082 PetscCall(DMSwarmDestroyGlobalVectorFromField(sw, DMSwarmPICField_coor, &gc)); in SetUpMigrateParticles()
1083 PetscCall(DMSwarmCreateGlobalVectorFromField(sw, "velocity", &gv)); in SetUpMigrateParticles()
1085 PetscCall(DMSwarmDestroyGlobalVectorFromField(sw, "velocity", &gv)); in SetUpMigrateParticles()
1092 DM sw; in MigrateParticles() local
1095 PetscCall(TSGetDM(ts, &sw)); in MigrateParticles()
1096 PetscCall(DMSwarmMigrate(sw, PETSC_TRUE)); in MigrateParticles()
1105 DM dm, sw; in main() local
1114 PetscCall(CreateSwarm(dm, &user, &sw)); in main()
1115 PetscCall(DMSetApplicationContext(sw, &user)); in main()
1119 PetscCall(TSSetDM(ts, sw)); in main()
1137 PetscCall(DMDestroy(&sw)); in main()